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

BSON.calculateObjectSize does not handle BigInt

    • 0
    • 2
    • Not Needed
    • Not Needed

      BSON.calculateObjectSize reports incorrect sizes when using BigInt.

      In most cases it the effect is minor, but I have cases where it causes a bulkWrite / insertMany command to fail with an error like this:

      MongoBulkWriteError: BSONObj size: 16814023 (0x1008FC7) is invalid. Size must be between 0 and 16793600(16MB) First element: insert: "mycollection"

      Because the calculated size is less than the actual size, the batch split is done at the incorrect point, causing failures.

      Here is a contrived script demonstrating the issue: https://gist.github.com/rkistner/467d2c91b985d4b89ef86720a38ec30e

      Also see an example of this happening in real life (with a workaround of limiting batches to 15MB): https://github.com/powersync-ja/powersync-service/pull/154

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            ralf@journeyapps.com Ralf Kistner
            Daria Pardue
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: