npm mongodb 7.2.0
v7.2.0

8 hours ago

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 Uint8Array APIs instead of the Node‑specific Buffer APIs.
  • The driver now uses the standard Web Crypto API globalThis.crypto instead of the Node‑specific crypto API.

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:

  1. If no runtimeAdapter is provided for a core Nodejs module that the driver uses, the driver will import the corresponding module from Nodejs.
  2. Adapters are per-client.
  3. 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.
  4. The runtimeAdapters Typescript types currently rely on Nodejs' type definitions (@types/node). To use runtimeAdapters in a Typescript project, @types/node must be installed as well.
  5. When providing a module in runtimeAdapters, all required functions inside that module must be provided. For example, when injecting the os module, the platform() 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

Documentation

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

Don't miss a new mongodb release

NewReleases is sending notifications on new releases.