Skip to content

Releases: mongodb/js-bson

v7.3.3

Choose a tag to compare

@github-actions github-actions released this 15 Sep 21:35
7b8f7b7

7.3.3 (2026-09-11)

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

Release Notes

Fixed BSON.calculateObjectSize infinite hang

Fixed a bug where BSON.calculateObjectSize would hang indefinitely on an object containing a circular reference. The method now throws an exception when a circular reference is detected.

Also a big thank you to @mcmorisi for his contribution on #912 security warning in EJSON.parse documentation!

Bug Fixes

  • NODE-7696: calculateObjectSize hangs indefinitely on an object containing a circular reference (#926) (f35af5c)

Documentation

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

v7.3.2

Choose a tag to compare

@github-actions github-actions released this 11 Aug 21:15
9cd2e68

7.3.2 (2026-07-31)

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

Release Notes

calculateObjectSize() now returns accurate byte counts for Int32 and BSONSymbol

Previously, each Int32 or BSONSymbol value caused a 12-byte overcount.

calculateObjectSize() now yields proper size calculations on ES Map's

This release of js-bson fixes an issue where we were incorrectly considering ES Map objects inside calculateObjectSize. This issue did not impact serialization, just size calculation.

Fixed incorrect date boundary in relaxed EJSON

This release of js-bson fixes an issue where the date boundary for relaxed EJSON was incorrectly set to a date 5 hours after the maximum limit of 10,000 AD.

Fixed an issue with ObjectId initialization in Cloudflare Workers

This release of js-bson fixes an issue where we were making crypto calls during module initialization, which is forbidden by Cloudflare Workers and other environments.

Memory optimization via smaller ObjectIds

ObjectId now stores its 12 bytes as four inline integers instead of a Uint8Array, cutting per-ObjectId memory by about 63% (and roughly 45 to 47% across large result sets) with no serialization slowdown. Deep equality and cloning are preserved (assert.deepStrictEqual, and lodash isEqual / cloneDeep).

Thanks to @spokodev for contributing their fixes! (NODE-7631 (#901), NODE-7645 (#917), NODE-7646 (#910))

Bug Fixes

Performance Improvements

Documentation

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

v7.3.1

Choose a tag to compare

@github-actions github-actions released this 24 Jun 16:12
31bed5d

7.3.1 (2026-06-23)

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

Release Notes

ObjectId initialization now tolerates partial process polyfills

Adds optional chaining to Node.js startup snapshot API calls in ObjectId so that environments with a stubbed or partial process global no longer throw a TypeError at startup.

Bug Fixes

Documentation

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

v7.3.0

Choose a tag to compare

@github-actions github-actions released this 17 Jun 16:14
2f7fdb1

7.3.0 (2026-06-17)

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

Release Notes

Deprecated inapplicable Long members on Timestamp

Timestamp inherits from Long for storage convenience, but it is semantically a (t, i) pair, not a general 64-bit integer. If you have called Long methods directly on Timestamp instances (for example toNumber(), getHighBits(), getLowBits(), or aithmetic and bitwise operations), those are now marked @deprecated with no runtime behavior changes. The .t and .i accessors provide direct, semantically consistent access to the two timestamp components.

BSON operations no longer throw on deeply nested documents

Core serialization and deserialization function (serialize, deserialize, calculateObjectSize) have been rewritten as iterative algorithms, so a sufficiently-nested document will no longer exhaust the call stack.

Behavior change: Code with Scope scopes are no longer promoted to DBRef

As a side effect of the rewrite, a Code with Scope scope that happens to carry $ref, $id, and $db keys is no longer promoted to a DBRef instance. The scope is returned as a plain object, which is the correct behavior: a scope represents JavaScript variable bindings, not a document reference.

new Binary(buffer, subType) now coerces subType to match BSON bytes

The Binary constructor now normalizes subtype inputs to match BSON serialization. Previously, passing a stringified subtype like '4' would cause a mismatch between the sub_type property (string '4') and the serialized BSON value (0x04). The constructor now converts inputs to ensure consistency.

EJSON.stringify now correctly handles all parameter combinations

Previously, calling EJSON.stringify(value, options, space) silently discarded the space parameter, producing unformatted output. This has been fixed so all documented call signatures work as expected:

// This now correctly produces indented canonical EJSON
EJSON.stringify(doc, { relaxed: false }, 2);

Thanks to @chdanielmueller for working on this problem!

ObjectId generates unique values across Node.js startup snapshot processes

ObjectId now resets its random state (process-unique bytes and counter seed) when a process restores from a Node.js startup snapshot. Previously these values were frozen into the snapshot blob, causing processes restored from the same snapshot to generate colliding ObjectIds.

Features

Bug Fixes

Documentation

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

v7.2.0

Choose a tag to compare

@github-actions github-actions released this 03 Feb 19:19
0712bb1

7.2.0 (2026-01-29)

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

Release Notes

EJSON now supports ignoreUndefined

serialize supports an option, ignoreUndefined, which instructs the serializer to skip any keys whose values are undefined.

This option has been added to EJSON:

> EJSON.stringify({ a: undefined }, { ignoreUndefined: true });
'{}'
> EJSON.stringify({ a: undefined }, { ignoreUndefined: false });
'{"a":null}'
> EJSON.serialize({ a: undefined }, { ignoreUndefined: true });
{}
> EJSON.serialize({ a: undefined }, { ignoreUndefined: false });
{ a: null }

This option defaults to false.

Buffer.copy() now present in ByteUtils

ByteUtils now contains a copy() method, we behaves identically to Nodejs' Buffer.copy() method.

Features

Documentation

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

v7.1.1

Choose a tag to compare

@github-actions github-actions released this 17 Jan 00:57
51f86bc

7.1.1 (2026-01-17)

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

Release Notes

Fix breaking change to onDemand namespace

This fix reverts the breaking change made as part of NODE-7334 and restores compatibility with v7.0.0 of the MongoDB Node.js Driver.

Bug Fixes

Documentation

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

v7.1.0

Choose a tag to compare

@github-actions github-actions released this 16 Jan 21:12
4375ec6

Caution

This release contains an inadvertent breaking change and has been deprecated on npm.

7.1.0 (2026-01-16)

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

Release Notes

ByteUtils added as a binary utillity

ByteUtils are now public and provide set of platform-agnostic tools to manipulate binary data (using Buffer in nodejs-compatible environments and fallback to Uint8Array).

Note

This feature is experimental and may change at any time

NumberUtils is now exported in the library

BSON maintains a set of utilities for reading to and from buffers of bytes. This module is now exported from the BSON package.

import { NumberUtils } from 'bson';

Note

NumberUtils is experimental and may change at any time.

ByteUtils and NumberUtils removed from onDemand namespace

The experimental ByteUtils and NumberUtils helpers have been moved from the onDemand namespace to the top-level package export.

Features

Bug Fixes

Documentation

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

v7.0.0

Choose a tag to compare

@github-actions github-actions released this 05 Nov 18:43
988fa17

7.0.0 (2025-11-05)

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

Release Notes

⚠ Breaking Changes

Minimum supported Node.js version now 20.19.0

The minimum supported Node.js version is now v20.19.0. We strive to keep our minimum supported Node.js version in sync with the runtime's release cadence to keep up with the latest security updates and modern language features. Our TypeScript target has also been updated to ES2023.

BSON now requires BigInt literal support

BSON now uses Javascript BigInt syntax and requires a JS engine with support for BigInt literal syntax.

All BSON bundles now use globalThis.crypto for random byte generation

Until BSON@7.x, BSON has supported Node.js v16. Node.js v16 does not include crypto in the global object, which necessitated importing crypto from node:crypto. This require has caused many headaches for bundlers. We improved the situation in NODE-6074, but this release updates our Node.js bundle to rely on the global object instead and removes all requires from the bundle.

BSON no longer vendors atob, btoa, and TextEncoder for react native builds

The React Native JS engine (Hermes) now supports atob, btoa, and TextEncoder natively and polyfills are no longer needed. BSON no longer includes these polyfills for react native builds.

ObjectId constructor no longer accepts a number

If you wish to create an ObjectId from a numeric timestamp, use ObjectId.createFromTime() instead.

BSON Binary subtype 2 constant deprecated

BSON Binary subtype 2 was previously deprecated in the BSON specification, but the corresponding subtype constant remained available in the BSON library. This constant has now been deprecated to align with the specification.

Non-breaking Features

New bsonType symbol property as an alias for _bsontype

JS classes representing BSON values now have a bsonType symbol property as an alias for the existing _bsontype property. This makes it easier to distinguish between values of a specific BSON type and documents with arbitrary keys after deserializing:

import { bsonType, deserialize } from 'bson';

const doc = deserialize(...);
// will be set when doc.value is a BSON wrapper class **or** a sub-document { _bsontype: '...' } 
console.log(doc.value._bsontype); 
// will be set if and only if doc.value is a BSON wrapper class
console.log(doc.value[bsonType]);

It is safe to replace all uses of value._bsontype with value[bsonType].

All Changes

Documentation

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

v7.0.0-alpha.2

v7.0.0-alpha.2 Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 24 Oct 19:02
f8400f6

7.0.0-alpha.2 (2025-10-24)

Bug Fixes

v7.0.0-alpha.1

v7.0.0-alpha.1 Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 21 Oct 19:45
625bf7e

7.0.0-alpha.1 (2025-10-21)

⚠ BREAKING CHANGES

  • bump BSON_MAJOR_VERSION to 7 (#832)

Features