-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: BSON
-
Empty show more show less
-
Not Needed
This is very similar in structure to NODE-2848, but doesn’t involve multiple BSON versions, only the browser and the Node.js distribution variants.
The root cause and the ideal fix are the same (namely, the `buffer` package fixing its instance checking, e.g. this PR). The main point of opening a new ticket is that, since Compass uses the 4.x driver, NODE-2848 is no longer as urgent for us, whereas this one is required for us to use the latest BSON version in Compass.
Steps to reproduce is running the shell script below:
npm install bson@4.4.0 cp node_modules/bson/dist/bson.browser.esm.js bson.browser.esm.mjs cat > test.mjs <<- EOS import bsonBrowser from './bson.browser.esm.mjs'; import bsonNode from 'bson'; console.log(bsonNode.serialize({ _id: new bsonBrowser.ObjectId() })); EOS node test.mjs # fails with: # # file:///tmp/v/bson.browser.esm.mjs:1775 # if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer'); # ^ # # TypeError: argument should be a Buffer # at Uint8Array.copy (file:///tmp/v/bson.browser.esm.mjs:1775:41) # at serializeObjectId (/tmp/v/node_modules/bson/lib/parser/serializer.js:222:18) # at Object.serializeInto (/tmp/v/node_modules/bson/lib/parser/serializer.js:801:25) # at Object.serialize (/tmp/v/node_modules/bson/lib/bson.js:117:43) # at file:///tmp/v/test.mjs:4:22 # at ModuleJob.run (internal/modules/esm/module_job.js:152:23) # at async Loader.import (internal/modules/esm/loader.js:177:24) # at async Object.loadESM (internal/process/esm_loader.js:68:5)
- is depended on by
-
COMPASS-4502 Update bson to real version in compass-import-export
- Closed
- is related to
-
NODE-6301 bson node es6 module import issue inside react app
- Closed
-
COMPASS-4903 Fix use of bson in Compass
- Closed
- related to
-
NODE-2848 bson@4.2.0 breaks serialization with bson@1.x
- Backlog
-
NODE-6321 Remove import of crypto from js-bson
- Blocked
-
NODE-5773 Cant use BSON ObjectId in browser
- Closed
-
NODE-5816 NextJS 14 await is not defined
- Closed