github mongodb/js-bson v7.3.4

5 hours ago

7.3.4 (2026-11-05)

The MongoDB Node.js team is pleased to announce version 7.3.4 of the bson package!

Release Notes

BSON.onDemand.parseToElements no longer hangs on malformed input

A malformed document containing a string element with a declared length of zero previously caused a non-terminating scan (synchronous CPU hang). The experimental on-demand parser now throws a BSONOffsetError instead.

Thanks to @AbinMadathil07 for providing the fix!

calculateObjectSize() now returns the correct size for negative zero

Previously, calculateObjectSize() counted -0 as a 4-byte int32, but serialize() writes it as an 8-byte double so the sign is kept. This made the result 4 bytes too small for every -0 in a document. Serializing into a buffer sized from that result (for example with serializeWithBufferAndIndex) would throw an out-of-bounds error. Thanks to @spokodev for the fix!

calculateObjectSize() now returns the correct size for a Code with an empty scope

Previously, calculateObjectSize() counted a Code whose scope is an empty object (for example new Code('x', {})) as plain code, but serialize() writes it as code with scope. The result was 9 bytes too small for each such value. Serializing into a buffer sized from that result (for example with serializeWithBufferAndIndex) would throw an out-of-bounds error. The two functions now agree. Thanks to @spokodev for the fix!

ObjectId no longer throws at import-time

Guards against throws at import-time in the Next.js Edge & Bun runtimes, which occur when the static ObjectId initializer calls specific optional APIs: getBuiltinModule and isBuildingSnapshot, which are implemented with a throwing stub.

Bug Fixes

Documentation

We invite you to try the bson library immediately, and report any issues to the NODE project.

Don't miss a new js-bson release

NewReleases is sending notifications on new releases.