Skip to content

string length limit of 9135? unclear why .on does not fire #1401

Description

@bradwbradw

When sending an object with a value that is a long string, and gradually increasing the string length, it gets to a point where .on will simply stop calling the passed in handler (it stops logging to console in the fn body). It's unclear why or where the exception is occurring, if it's in the .on callback, or the data intake step, or what. Would be nice if there was a way to catch and show this error.

nodeJS instance 1:


    var gun = Gun({
        radisk: false,
        web: server,
        localStorage: false,
        axe: false
    });

    gun.get("a/a").on((data, key) => {
                    console.log(key, data);
    });

nodeJS instance 2:


var gun = Gun({ 
  radisk: false, 
  axe: false, 
  localStorage: false, 
  peers:[localhost:8765/gun] 
});

var range = (start, end, step = 1) => {
  let result = [];
  for(let i=0; i<=end; i+=step) {
    result.push(i);
  }
  return result;
};

var count = 0;
setInterval(() => {

  var longString = range(0, 9134).map(() => "a").join("")+(count++);
  gun.get('a/a').put({a:longString});
},1000);

I see the console logging every 1 second, there is a long string of a's terminated with the count, increasing with each log call, until it reaches the digit "9" then it does not progress to "10". I found this apparent limit of 9135 experimentally. Any strings larger than 9134 make gun stop working, somehow.

My actual data is an array and I'm encoding it to JSON to get around the "no arrays" limitation. Am I doing something wrong? Is there a config option or any suggestions I can try that can unlock longer string values?

Thanks for your time

Activity

  1. amark commented on Jun 16, 2025

    @amark
    Owner

    @bradwbradw just seeing this now (sorry, idk but my GitHub notifications seem broken)

    this is scary!

    So I just tried replicating and could not: things worked fine. What GUN version are you using? If you use latest GitHub does it work fine?

    We've been regularly (tho not recommended) sending base64 image/video frames over GUN with MUCH higher string length, so I suspect it is something else going. Let me know if latest GitHub version fixes it or if still an issue. Thanks!

  2. bradwbradw commented on Jun 16, 2025

    @bradwbradw
    ContributorAuthor
  3. bradwbradw commented on Jun 17, 2025

    @bradwbradw
    ContributorAuthor

    @amark when you reproduced it, did you use two scripts that shared the same dependency tree (node_modules dir) or did you use two separate dirs each with their own set of deps?

  4. amark commented on Jun 26, 2025

    @amark
    Owner

    @bradwbradw try disabling UDP (lib/multicast.js) and see what happens?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions