7.2.0 (2026-04-17)
The MongoDB Node.js team is pleased to announce version 7.2.0 of the mongodb package!
Release Notes
⚙️ Added support for MongoDB's Intelligent Workload Management
Added support for MongoDB's Intelligent Workload Management (IWM) and ingress connection rate limiting features. The driver now gracefully handles write-blocking scenarios and optimizes connection establishment during high-load conditions to maintain application availability.
Two new client options are available:
maxAdaptiveRetries(default: 2) - configures the maximum number of retries during server overload. Set to 0 to disable overload retries.enableOverloadRetargeting(default: false) - when enabled, the driver will deprioritize servers that return overload errors during retry server selection.
🧩 Runtime and platform compatibility improvements
Node-specific platform APIs replaced with standards-based equivalents
The following Node-specific APIs have been replaced with standards-based equivalents:
- The driver now uses the standard
Uint8ArrayAPIs instead of the Node‑specificBufferAPIs. - The driver now uses the standard Web Crypto API
globalThis.cryptoinstead of the Node‑specificcryptoAPI.
These changes reduce the number of patches required to run the driver outside of Node.js and improve compatibility with non-Node.js runtimes.
Experimental Support for Dependency Injection of Nodejs Runtime Dependencies
This release introduces a new MongoClient option, runtimeAdapters. runtimeAdapters allows injection of core Nodejs APIs, to allow users of the driver to use alternative runtimes that don't support Nodejs compatibility or work in restricted environments.
Warning
runtimeAdapters is experimental and the actual interface of each dependency might change at any time.
Notes about usage of runtimeAdapters:
- If no
runtimeAdapteris provided for a core Nodejs module that the driver uses, the driver will import the corresponding module from Nodejs. - Adapters are per-client.
- Each adapter specifies the required APIs as a part of its Typescript API definition. There are no runtime checks to ensure all required functions are provided; the onus is on users to ensure that all required module dependencies are provided.
- The
runtimeAdaptersTypescript types currently rely on Nodejs' type definitions (@types/node). To useruntimeAdaptersin a Typescript project,@types/nodemust be installed as well. - When providing a module in
runtimeAdapters, all required functions inside that module must be provided. For example, when injecting theosmodule, theplatform()function cannot be omitted.
runtimeAdapters supports injecting Nodejs' os module
The os module is pluggable using runtimeAdapters:
const os: OsAdapter = {
// implement the required OSAdapter interface
}
// `client` will never import or make use of the `os` module and instead only rely on the `os` adapter specified above.
const client = new MongoClient(<uri>, {
runtimeAdapters: { os }
});☀️ ChangeStreams now have a bufferedCount() method that matches cursors
In some circumstances it may be desirable to determine if there are local documents stored in your change stream before invoking one of the async methods (tryNext, hasNext etc.). The changeStream.bufferedCount() returns the number of documents remaining inside the change stream from the last batch.
Shout out to @typesafe for contributing this feature!
Features
- NODE-7315: Use BSON ByteUtils instead of Nodejs Buffer (#4840) (1add538)
- NODE-7379: Refactor Crypto to Web Crypto API (#4862) (ac98f4a)
- NODE-7385: add experimental
osruntime adapter (#4851) (d2ad07f) - NODE-7441: add
ChangeStream.bufferedCount(#4870) (f7ea421) - NODE-7142: Exponential backoff and jitter in retry loops (#4871) (22c6031)
- NODE-7452: restrict server deprioritization on replica sets to overload errors (#4875) (87a3465)
- NODE-7467: make token bucket optional in client backpressure (#4878) (4fb0a0a)
- NODE-7491: finalize client backpressure implementation for phase 1 rollout (#4920) (2cc7983)
Documentation
We invite you to try the mongodb library immediately, and report any issues to the NODE project.