-
Type:
Bug
-
Resolution: Won't Fix
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: BSON
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.