-
Type: Bug
-
Resolution: Done
-
Priority: Critical - P2
-
None
-
Affects Version/s: None
-
Component/s: BSON
-
Not Needed
Due to https://github.com/nodejs/node/issues/54543, when the following is run in Node v22.7.0, invalid BSON can be produced.
import { BSON } from "mongodb"; const value = 'bébé'; async function run() { console.log(BSON.serialize({ _id: 1, message: value })); let i = 0; while (Buffer.from(value).length === 6 && i < 20000) { i++ } console.log(BSON.serialize({ _id: 1, message: value })); } run().catch(console.dir);
// output
<Buffer 22 00 00 00 10 5f 69 64 00 01 00 00 00 02 6d 65 73 73 61 67 65 00 07 00 00 00 62 c3 a9 62 c3 a9 00 00>
<Buffer 20 00 00 00 10 5f 69 64 00 01 00 00 00 02 6d 65 73 73 61 67 65 00 05 00 00 00 62 e9 62 e9 00 00>
- is related to
-
NODE-6355 enableUtf8Validation on cursors broken in 6.8.0
- Closed
-
MONGOSH-1866 Mongosh v2.3.0 is relying on NodeJS v22.7.0 that is known to cause invalid BSON encoding
- Closed
- related to
-
SERVER-93732 The server should reject inserting/updating strings containing invalid UTF-8
- Needs Scheduling