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

BSON-EXT: Uncaught Assertion failed during object serialize

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: BSON
    • Labels:
    • Not Needed

      The c++ implementation of BSON returns Uncaught Assertion failed from c++ code instead of a proper catchable node js error.

       

      The problem happens in case you are trying to serialize an object with the key name `toString` using serialize method.

      Way to replicate the bug:

      test.js

      ```
      const BSON = require('bson-ext');

      BSON.serialize({
        toString: {},
      });

      ```

      Run the code

      `node test.js`

      The process crashed with output
      ```
      Assertion failed: (!h.IsEmpty()), function Unmaybe, file ../src/bson.h, line 60.
      ```

      see https://github.com/mongodb-js/bson-ext/blob/4.0/src/bson.h#L60

       

      It is not possible to catch this error in node js. In our case, it crashes our API server and takes some time to debug this issue.

       

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            jakub.drobnik@apify.com Jakub Drobnik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: