Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3226

EJSON.serialize() overflows stack for circular references in input

    • Not Needed

      This is more of an UX thing, but it would be nice if EJSON.stringify/serialize threw a more actionable error like JSON.stringify() when encountering circular input.

      > const c = {}; c.c = c;
      <ref *1> { c: [Circular *1] }
      > require('bson').EJSON.serialize(c)
      Uncaught RangeError: Maximum call stack size exceeded
          at Function.isArray (<anonymous>)
          at serializeValue (/home/addaleax/src/mongosh/node_modules/bson/lib/extended_json.js:130:15)
          at serializeDocument (/home/addaleax/src/mongosh/node_modules/bson/lib/extended_json.js:203:26)
      

            Assignee:
            eric.adum@mongodb.com Eric Adum (Inactive)
            Reporter:
            anna.henningsen@mongodb.com Anna Henningsen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: