MongoDB Node.js Driver

Databases & Data

The official MongoDB driver for Node.js.

Latest v7.5.0 · by MongoDBWebsitemongodb/node-mongodb-native

Release activity

Release activity — 10 releases across 10 days since Aug 26, 2025. Each cell is one day; darker means more releases that day. Nothing is recorded before Aug 26, 2025. Older weeks are hidden at this screen width.
MayJunJulAug
SundayNo releases on May 3, 2026No releases on May 10, 2026No releases on May 17, 2026No releases on May 24, 2026No releases on May 31, 2026No releases on Jun 7, 2026No releases on Jun 14, 2026No releases on Jun 21, 2026No releases on Jun 28, 2026No releases on Jul 5, 2026No releases on Jul 12, 2026No releases on Jul 19, 2026No releases on Jul 26, 2026No releases on Aug 2, 2026No releases on Aug 9, 2026No releases on Aug 16, 2026
MondayNo releases on May 4, 2026No releases on May 11, 2026No releases on May 18, 2026No releases on May 25, 2026No releases on Jun 1, 2026No releases on Jun 8, 2026No releases on Jun 15, 2026No releases on Jun 22, 2026No releases on Jun 29, 2026No releases on Jul 6, 2026No releases on Jul 13, 2026No releases on Jul 20, 2026No releases on Jul 27, 2026No releases on Aug 3, 2026No releases on Aug 10, 2026No releases on Aug 17, 2026
TuesdayNo releases on May 5, 2026No releases on May 12, 2026No releases on May 19, 2026No releases on May 26, 2026No releases on Jun 2, 20261 release on Jun 9, 2026No releases on Jun 16, 2026No releases on Jun 23, 2026No releases on Jun 30, 20261 release on Jul 7, 2026No releases on Jul 14, 2026No releases on Jul 21, 2026No releases on Jul 28, 2026No releases on Aug 4, 2026No releases on Aug 11, 2026No releases on Aug 18, 2026
WednesdayNo releases on May 6, 2026No releases on May 13, 2026No releases on May 20, 2026No releases on May 27, 2026No releases on Jun 3, 2026No releases on Jun 10, 2026No releases on Jun 17, 2026No releases on Jun 24, 2026No releases on Jul 1, 2026No releases on Jul 8, 2026No releases on Jul 15, 2026No releases on Jul 22, 2026No releases on Jul 29, 2026No releases on Aug 5, 2026No releases on Aug 12, 2026No releases on Aug 19, 2026
ThursdayNo releases on May 7, 2026No releases on May 14, 2026No releases on May 21, 2026No releases on May 28, 2026No releases on Jun 4, 2026No releases on Jun 11, 2026No releases on Jun 18, 20261 release on Jun 25, 2026No releases on Jul 2, 2026No releases on Jul 9, 2026No releases on Jul 16, 2026No releases on Jul 23, 2026No releases on Jul 30, 2026No releases on Aug 6, 2026No releases on Aug 13, 2026
FridayNo releases on May 8, 2026No releases on May 15, 2026No releases on May 22, 2026No releases on May 29, 2026No releases on Jun 5, 2026No releases on Jun 12, 2026No releases on Jun 19, 2026No releases on Jun 26, 2026No releases on Jul 3, 2026No releases on Jul 10, 2026No releases on Jul 17, 2026No releases on Jul 24, 2026No releases on Jul 31, 2026No releases on Aug 7, 2026No releases on Aug 14, 2026
SaturdayNo releases on May 9, 2026No releases on May 16, 2026No releases on May 23, 2026No releases on May 30, 2026No releases on Jun 6, 2026No releases on Jun 13, 2026No releases on Jun 20, 2026No releases on Jun 27, 2026No releases on Jul 4, 2026No releases on Jul 11, 2026No releases on Jul 18, 2026No releases on Jul 25, 2026No releases on Aug 1, 2026No releases on Aug 8, 2026No releases on Aug 15, 2026

10 releases since Aug 26, 2025

Changelog

v7.5.0

Latest
Added 1
  • Support for Queryable Encryption string queries in MongoDB 9.0 with exact and range-style string matching against encrypted fields
Changed 2
  • TextOpts API is replaced with StringOpts
  • TextPreview algorithm is replaced with String
Fixed 1
  • MongoClient.close() now closes checked-out connections on all servers in replica sets and sharded clusters
Deprecated 1
  • prefixPreview, suffixPreview, and substringPreview query types are deprecated and will be removed in a future release

From MongoDB Node.js Driver

7.5.0 (2026-07-07)

The MongoDB Node.js team is pleased to announce version 7.5.0 of the mongodb package!

Release Notes
Support for Queryable Encryption String Query GA in MongoDB 9.0

Queryable Encryption string queries are now available for MongoDB 9.0. Building on the technical preview introduced in earlier releases, this feature lets you run exact and range-style string matching against encrypted fields. As part of the promotion to GA, the API has been renamed:

  • The TextOpts API is replaced with StringOpts.
  • The TextPreview algorithm is replaced with String.
  • The prefix, suffix, and substring query types are now generally available.
  • The prefixPreview, suffixPreview, and substringPreview query types are deprecated and will be removed in a future release.
MongoClient.close() now closes in-use connections on all servers

Since v6.17.0, MongoClient.close() has eagerly closed checked-out (in-use) connections so that in-flight operations are interrupted promptly with a MongoClientClosedError instead of holding the client open. However, due to a bug, on replica sets and sharded clusters operations in flight on other servers were not interrupted, and their connections stayed open until the operations completed on their own. Calls to closeCheckedOutConnections() will now ensure all checked out connections are closed across all servers.

Thank you to @Nepomuk5665 and @sarthaksoni25 for bringing this to our attention/providing an initial implementation!

Features
  • NODE-7537: promote QE string queries (prefix/suffix/substring) (#4996) (dc4900c)
Bug Fixes
Documentation

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

View originalPermalink
How v7.5.0 went

v7.4.0

Changed 2
  • Remove experimental tag from Symbol.asyncDispose methods on MongoClient, ClientSession, ChangeStream, and cursors to mark explicit resource management as stable
  • Send afterClusterTime on writes in causally-consistent sessions to maintain read your own writes guarantee across primary failovers in sharded clusters

From MongoDB Node.js Driver

7.4.0 (2026-06-25)

The MongoDB Node.js team is pleased to announce version 7.4.0 of the mongodb package!

Release Notes
Explicit resource management is now stable

The Symbol.asyncDispose methods on MongoClient, ClientSession, ChangeStream, and cursors enable await using for automatic cleanup. These methods were introduced as experimental in v6.9.0. Since then, TC39 Explicit Resource Management proposal reached Stage 4 in 2025, and Node.js enabled explicit resource management as a stable feature in Node.js 24, so the experimental flags have been removed from our APIs and the APIs are now officially supported.

afterClusterTime now sent on writes in causally-consistent sessions

When a session has causal consistency enabled, write operations now include readConcern.afterClusterTime, matching the existing read behavior. This maintains the "read your own writes" guarantee across primary failovers in shareded clusters. There are no API changes.

Features
  • NODE-7634: remove experimental tag from async dispose methods (#4976) (43ce3eb)
  • NODE-7549: send afterClusterTime on writes in causally-consistent sessions (#4963) (3abfd26)
Documentation

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

View originalPermalink
How v7.4.0 went

v7.3.0

Changed 1
  • Bump maxWireVersion to 29 in preparation for MongoDB LTS v9.0
Fixed 1
  • Fix SCRAM authentication for non-Node.js runtimes such as Deno by using explicit UTF-8 string conversion instead of implicit toString() calls on byte arrays

From MongoDB Node.js Driver

[!IMPORTANT] A future minor release will raise the minimum supported MongoDB Server version from 4.2 to 4.4. This is in accordance with MongoDB Software Lifecycle Schedules. Support for MongoDB Server 4.2 will be dropped in a future release!

7.3.0 (2026-06-04)

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

Release Notes
maxWireVersion is bumped to 29

Max wire version & max server version bumped in preparation for MongoDB LTS (v9.0).

Fixed SCRAM authentication for non-Node.js runtimes (e.g., Deno)

SCRAM-based authentication (the default mechanism for username/password connections) was broken when using the driver in non-Node.js environments such as Deno. The root cause was an implicit toString() call on byte arrays that produced incorrect output outside of Node.js. This fix ensures explicit UTF-8 string conversion is used throughout the SCRAM implementation, restoring authentication in Deno and other web-compatible runtimes.

Features
Bug Fixes
  • NODE-7548: SCRAM authentication fails on non-Node runtimes (#4932) (a10d2c9)
Documentation

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

View originalPermalink
How v7.3.0 went

v7.2.0

Added 6
  • Support for MongoDB's Intelligent Workload Management with graceful handling of write-blocking scenarios and optimized connection establishment during high-load conditions
  • New client option `maxAdaptiveRetries` (default: 2) to configure the maximum number of retries during server overload
  • New client option `enableOverloadRetargeting` (default: false) to deprioritize servers that return overload errors during retry server selection
  • Experimental `runtimeAdapters` client option to allow injection of core Node.js APIs for use in alternative runtimes and restricted environments
  • Support for injecting Node.js `os` module via `runtimeAdapters`
  • Add `bufferedCount()` method to ChangeStream to return the number of documents remaining in the change stream from the last batch
Changed 3
  • Replace Node-specific Buffer APIs with standard Uint8Array APIs
  • Replace Node-specific crypto API with standard Web Crypto API `globalThis.crypto`
  • Implement exponential backoff and jitter in retry loops

From MongoDB Node.js Driver

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.

These features will be functional with MongoDB Atlas Server Version 9.0 and above.

🧩 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
  • 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 os runtime 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.

View originalPermalink
How v7.2.0 went

v7.1.1

Fixed 2
  • Tighten OIDC ALLOWED_HOSTS wildcard matching to require full subdomain/path matches for *. and */ entries, preventing partial suffix matches from being incorrectly accepted
  • Apply TCP keep-alive and no-delay settings on TLS connections by explicitly calling setKeepAlive() and setNoDelay() on the socket after creation

From MongoDB Node.js Driver

7.1.1 (2026-03-24)

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

Release Notes
Tighten OIDC ALLOWED_HOSTS wildcard matching

The OIDC ALLOWED_HOSTS wildcard handling has been fixed to require full subdomain/path matches for *. and */ entries, preventing partial suffix matches from being incorrectly accepted.

Fixed TCP keep-alive and no-delay settings not being applied on TLS connections

Due to a Node.js bug, tls.connect() silently ignores keepAlive, keepAliveInitialDelay, and noDelay options passed through its constructor. This could cause idle connections - particularly through cloud load balancers like Azure (240s idle timeout) or AWS PrivateLink/NLB - to be dropped unexpectedly due to missing TCP keep-alive probes.

The driver now explicitly calls setKeepAlive() and setNoDelay() on the socket after creation, ensuring these settings are always applied regardless of whether TLS is used.

Bug Fixes
  • NODE-7477: OIDC host allowlist fix (#4896) (237c9ab)
  • NODE-7482: explicitly call setKeepAlive and setNoDelay on socket (#4900) (b14ba21)
Documentation

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

View originalPermalink
How v7.1.1 went

v7.1.0

Changed 10
  • Driver no longer relies on Node.js util.promisify() API for improved compatibility with alternate runtimes
  • Driver now explicitly imports node:process instead of relying on global.process
  • Replace process.arch with os.arch()
  • Replace process.platform with os.platform()
  • Replace os.endianness() with BSON.NumberUtils
  • Replace process.hrtime() with performance.now()
Fixed 3
  • Connection establishment failures no longer clear the pool, preventing unnecessary connection churn in server overload scenarios
  • OIDC reauthentication now works with promoteValues: false
  • Aggregations with write stages now correctly respect secondary and secondaryPreferred read preferences due to corrected commonWireVersion initialization
Removed 1
  • aws4 package is no longer required for AWS authentication
Deprecated 1
  • RenameCollectionOptions.new_collection option is deprecated and will be removed in a future major release

From MongoDB Node.js Driver

7.1.0 (2026-02-02)

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

Release Notes
🧩 Runtime and platform compatibility improvements
aws4 package no longer required for AWS authentication

The aws4 package is no longer required to use AWS authentication, reducing the dependency footprint.

Usages of util.promisify have been removed

The driver no longer relies on Node.js’s util.promisify() API, which improves compatibility with alternate runtimes.

Explicit node:process import instead of global.process

The driver now explicitly imports node:process instead of relying on global.process, allowing bundlers and alternate runtimes to supply and optimize the process implementation more consistently.

Node-specific platform APIs replaced with standards-based equivalents

The driver replaces several Node-specific APIs with standards-based equivalents:

  • process.archos.arch()
  • process.platformos.platform()
  • os.endianness()BSON.NumberUtils
  • process.hrtime()performance.now()
  • process.nextTick()queueMicrotask()

These changes reduce the number of patches required to run the driver outside of Node.js and improve compatibility with non-Node.js runtimes.

🔁 Connection resilience and retry behavior improvements
Connection churn avoidance in server overload scenarios

When server-side connection rate limiting is enabled and the rate limiter kicks in under periods of high connection establishment,the driver will additionally churn connections by clearing the pool every time the rate limiter rejects an incoming connection request.

In this new driver release, connection establishment failures no longer clear the pool, preventing unnecessary connection churn in these scenarios.

withTransaction now applies exponential backoff during transaction retries

The convenient transaction API, withTransaction, now uses exponential backoff between retries when a transaction must be retried. Under high server load, this can help prevent transaction retry storms.

Server selection deprioritizes servers during retries

When retrying a command, the driver now deprioritizes servers during server selection, improving stability and reducing the likelihood of repeatedly targeting overloaded or previously failed servers.

🔐 OIDC authentication improvements
Expanded the list of ALLOWED_HOSTS for OIDC

OIDC authentication now supports hosts matching *.mongo.com in its default ALLOWED_HOSTS list.

OIDC reauthentication now works with promoteValues: false

When MongoClient is configured with promoteValues: false (for applications that rely on raw BSON types), OIDC reauthentication now succeeds as expected.

✅ Fixed read preference adherence for $merge and $out aggregations

Resolved an issue where the driver failed to detect MongoDB 5.0+ capabilities due to incorrect commonWireVersion initialization. As a result, aggregations with write stages now correctly respect secondary and secondaryPreferred read preferences, rather than forcing execution on the primary.

Huge thanks to @crehbichler for discovering and investigating this bug and for implementing a fix!

⚠️ Deprecations
RenameCollectionOptions.new_collection

This option has been unused since driver 4.x. It is now deprecated and will be removed in a future major release. Existing code that sets this option can safely remove it with no behavioral change.

Features
  • NODE-5393: aws4 no longer required for AWS authentication (#4824) (0f46db8)
  • NODE-7121: prevent connection churn on backpressure errors when establishing connections (#4800) (4cb2b87)
  • NODE-7122: exponential backoff between retries in convenient transaction API (#4765) (e70fdc9)
  • NODE-7304: remove usages in src of promisify (#4799) (761b9bf)
  • NODE-7306: Replace global process with import node:process (#4820) (cc503cb)
  • NODE-7310: Replace process.arch with os.arch() (#4823) (f0af829)
  • NODE-7311: Replace process.platform with os.platform() (#4822) (c58ca1f)
  • NODE-7317: use BSON.NumberUtils to determine endianness (#4808) (4e9467e)
  • NODE-7319: update allowed hosts list with *.mongo.com (#4802) (bfb7160)
  • NODE-7330: deprecate RenameCollectionOptions.new_collection (#4815) (a96fa26)
  • NODE-7333: add support for deprioritized servers to all topologies (#4821) (a4211e7)
  • NODE-7307: Replace node:process.hrtime() with performance.now() (#4816) (ae2e037)
  • NODE-7308: replace process.nextTick with queueMicrotask (#4817) (b1b6e81)
Bug Fixes
  • NODE-7290: use valueof for error code check (#4791) (1cc3d1c)
  • NODE-7298: ensure commonWireVersion is computed from server maxWireVersion (#4805) (2b2366d)
Documentation

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

View originalPermalink
How v7.1.0 went

v7.0.0

Added 1
  • Native support for explicit resource management with Symbol.asyncDispose implementations on MongoClient, ClientSession, ChangeStream and cursors
Changed 11
  • Minimum supported Node.js version is now v20.19.0
  • TypeScript target has been updated to ES2023
  • Driver updated to use bson@7.0.0 and mongodb-connection-string-url@7.0.0
  • Minimum version for @mongodb-js/zstd optional peer dependency raised to 7.0.0, dropped support for 1.x and 2.x
  • Minimum version for kerberos optional peer dependency raised to 7.0.0, dropped support for 2.x
  • Minimum version for mongodb-client-encryption optional peer dependency raised to 7.0.0, dropped support for 6.x
Fixed 2
  • All encryption-related errors now subclass MongoError
  • Fixed typo in error label from PoolRequstedRetry to PoolRequestedRetry
Removed 1
  • Explicitly provided credentials no longer accepted with MONGODB-AWS authentication in connection strings

From MongoDB Node.js Driver

7.0.0 (2025-11-06)

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

Release Notes

The following is a detailed collection of the changes in the major v7 release of the mongodb package for Node.js. The main focus of this release was usability improvements and a streamlined API. Read on for details!

[!IMPORTANT] This is a list of changes relative to v6.21.0 of the driver. ALL changes listed below are BREAKING unless indicated otherwise. Users migrating from an older version of the driver are advised to upgrade to at least v6.21.0 before adopting v7.

🛠️ Runtime and dependency updates
Minimum Node.js version is now v20.19.0

The minimum supported Node.js version is now v20.19.0 and our TypeScript target has been updated to ES2023. 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.

Notably, the driver now offers native support for explicit resource management. Symbol.asyncDispose implementations are available on the MongoClient, ClientSession, ChangeStream and on cursors.

[!Note] Explicit resource management is considered experimental in the driver and will be until the TC39 explicit resource management proposal is completed.

bson and mongodb-connection-string-url versions 7.0.0

This driver version has been updated to use bson@7.0.0 and mongodb-connection-string-url@7.0.0, which match the driver's Node.js runtime version support. BSON functionality re-exported from the driver is furthermore subject to the changes outlined in the BSON V7 release notes.

Optional peer dependency releases and version bumps
  • @mongodb-js/zstd optional peer dependency minimum version raised to 7.0.0, dropped support for 1.x and 2.x (note that @mongodb-js/zstd does not have 3.x-6.x version releases)
  • kerberos optional peer dependency minimum version raised to 7.0.0, dropped support for 2.x (note that kerberos does not have 3.x-6.x version releases)
  • mongodb-client-encryption optional peer dependency minimum version raised to 7.0.0, dropped support for 6.x

Additionally, the driver is now compatible with the following packages:

DependencyPrevious RangeNew Allowed Range
@aws-sdk/credential-providers^3.188.0^3.806.0
gcp-metadata^5.2.0^7.0.1
socks^2.7.1^2.8.6
🔐 AWS authentication

To improve long-term maintainability and ensure compatibility with AWS updates, we’ve standardized AWS auth to use the official SDK in all cases and made a number of supporting changes outlined below.

@aws-sdk/credential-providers is now required for MONGODB-AWS authentication

Previous versions of the driver contained two implementations for AWS authentication and could run the risk of the custom driver implementation not supporting all AWS authentication features as well as not being correct when AWS makes changes. Using the official AWS SDK in all cases alleviates these issues.

npm install @aws-sdk/credential-providers
Custom AWS credential provider takes highest precedence

When providing a custom AWS credential provider via the auth mechanism property AWS_CREDENTIAL_PROVIDER, it will now take the highest precedence over any other AWS auth method.

Explicitly provided credentials no longer accepted with MONGODB-AWS authentication

AWS environments (such as AWS Lambda) do not have credentials that are permanent and expire within a set amount of time. Providing credentials in the URI or options would mandate that those credentials would be valid for the life of the MongoClient, which is problematic. With this change, the fetching of credentials is fully handled by the installed required AWS SDK.

This means that for AWS authentication, all client URIs MUST now be specified as:

import { MongoClient } from 'mongodb';

const client = new MongoClient('mongodb<+srv>://<host>:<port>/?authMechanism=MONGODB-AWS');

The previous method of providing URI encoded credentials based on the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY directly in the connection string will no longer work.

⚙️ Error handling improvements
Dropping a collection returns false instead of throwing when NS not found

This change has been made for consistency with the common drivers specifications.

Aggregate with write concern and explain no longer throws client-side

This will now throw a MongoServerError instead.

All encryption-related errors now subclass MongoError

The driver aims to ensure that all errors it throws are subclasses of MongoError. However, when using CSFLE or QE, the driver's encryption implementation could sometimes throw errors that were not instances of MongoError.

Now, all errors thrown during encryption are subclasses of MongoError.

'PoolRequstedRetry' error label renamed to 'PoolRequestedRetry'

The PoolClearedError thrown in cases where the connection pool was cleared now fixes the typo in the error label.

💥 Misc breaking improvements
Change streams no longer filter $changeStream stage options

Users can now pass any option to collection.watch(). If an option is invalid for the $changeStream stage of the pipeline, the server will return an error. This change makes it possible to use newly introduced server options without waiting for them to become available in our public type definitions and eliminates the risk of valid but unrecognized options being silently ignored.

Cursors no longer provide a default batchSize of 1000 for getMores

In driver versions <7.0, the driver provides a default batchSize of 1000 for each getMore when iterating a cursor. This behavior is not ideal because the default is set regardless of the documents being fetched. For example, if a cursor fetches many small documents, the driver's default of 1000 can result in many round-trips to fetch all documents, when the server could fit all documents inside a single getMore if no batchSize were set.

Now, cursors no longer provide a default batchSize when executing a getMore. A batchSize will only be set on getMore commands if a batchSize has been explicitly configured for the cursor.

Auto encryption options now include default filenames in TS

A common source of confusion for people configuring auto encryption is where to specify the path to mongocryptd and where to specify the path to crypt_shared. We've now made this clearer in our Typescript users. Typescript now reports errors if the specified filename doesn't match the default name of the file. Some examples:

var path: AutoEncryptionOptions['extraOptions']['mongocryptdSpawnPath'] = 'some path'; // ERROR
var path: AutoEncryptionOptions['extraOptions']['mongocryptdSpawnPath'] = 'mongocryptd'; // OK
var path: AutoEncryptionOptions['extraOptions']['mongocryptdSpawnPath'] =
  '/usr/local/bin/mongocryptd'; // OK
var path: AutoEncryptionOptions['extraOptions']['mongocryptdSpawnPath'] = 'mongocryptd.exe'; // OK

var path: AutoEncryptionOptions['extraOptions']['cryptSharedLibPath'] = 'some path'; // ERROR
var path: AutoEncryptionOptions['extraOptions']['cryptSharedLibPath'] = 'mongo_crypt_v1.so'; // OK
var path: AutoEncryptionOptions['extraOptions']['cryptSharedLibPath'] = 'mongo_crypt_v1.dll'; // OK
var path: AutoEncryptionOptions['extraOptions']['cryptSharedLibPath'] = 'mongo_crypt_v1.dylib'; // OK
☀️ Misc non-breaking improvements
Improve MongoClient.connect() consistency across environments

The MongoClient connect function will now run a handshake regardless of credentials being defined. The upshot of this change is that connect is more consistent at verifying some fail-fast preconditions regardless of environment. For example, previously, if connecting to a loadBalanced=true cluster without authentication there would not have been an error until a command was attempted.

MongoClient.close() no longer sends endSessions if the topology does not have session support

MongoClient.close() attempts to free up any server resources that the client has instantiated, including sessions. Previously, MongoClient.close() unconditionally attempted to kill all sessions, regardless of whether or not the topology actually supports sessions.

Now, MongoClient.close() only attempts to clean up sessions if the topology supports sessions.

Wrap socket write in a try/catch to ensure errors can be properly wrapped

One socket.write call was not correctly wrapped in a try/catch block and network errors could bubble up to the driver. This call is now properly wrapped and will result in a retry.

ClientEncryption.rewrapManyDataKey() options now correctly marked as optional

The options parameter for the ClientEncryption.rewrapManyDataKey() method is now correctly marked as optional in its TypeScript definition. This change aligns the type signature with the method's implementation and documentation, resolving a type mismatch for TypeScript users.

📜 Removal of deprecated functionality
Cursor and ChangeStream stream() method no longer accepts a transform

Cursors and ChangeStreams no longer accept a transform function. ReadableStream.map() can be used instead:

// before
const stream = cursor.stream({ transform: JSON.stringify });

// after
const stream = cursor.stream().map(JSON.stringify);
MONGODB-CR AuthMechanism has been removed

This mechanism has been unsupported as of MongoDB 4.0 and attempting to use it will still raise an error.

Internal ClientMetadata properties have been removed from the public API

Previous versions of the driver unintentionally exposed the following properties that have now been made internal:

MongoClient.options.additionalDriverInfo
MongoClient.options.metadata
MongoClient.options.extendedMetadata
MongoOptions.additionalDriverInfo
MongoOptions.metadata
MongoOptions.extendedMetadata
ConnectionOptions.metadata
ConnectionOptions.extendedMetadata
CommandOptions.noResponse option removed

This option was never intended to be public, and never worked properly for user-facing APIs. It has now been removed.

Assorted deprecated type, class, and option removals
GridFSFile.contentType;
GridFSFile.aliases;
GridFSBucketWriteStreamOptions.contentType;
GridFSBucketWriteStreamOptions.aliases;
CloseOptions;
ResumeOptions;
MongoClientOptions.useNewUrlParser;
MongoClientOptions.useUnifiedTopology;
CreateCollectionOptions.autoIndexId;
FindOptions<TSchema>; // now no generic type
ClientMetadataOptions;
FindOneOptions.batchSize;
FindOneOptions.limit;
FindOneOptions.noCursorTimeout;
ReadPreference.minWireVersion;
ServerCapabilities;
CommandOperationOptions.retryWrites; // is a global option on the MongoClient
ClientSession.transaction;
Transaction;
CancellationToken;
⚠️ ALL BREAKING CHANGES
  • NODE-7286: Update dependencies to v7 (#4780)
  • NODE-5510: dont filter change stream options (#4723)
  • NODE-6296: remove cursor default batch size of 1000 (#4729)
  • NODE-7150: update peer dependency matrix for 3rd party peer deps (#4720)
  • NODE-7046: remove AWS uri/options support (#4689)
  • NODE-4808: remove support for stream() transform on cursors and change streams (#4728)
  • NODE-6377: remove noResponse option (#4724)
  • NODE-6473: remove MONGODB-CR auth (#4717)
  • NODE-5994: Remove metadata-related properties from public driver API (#4716)
  • NODE-7016: remove beta namespace and move resource management into driver (#4719)
  • NODE-4184: don't throw on aggregate with write concern and explain (#4718)
  • NODE-7043, NODE-7217: adopt mongodb-client-encryption v7 (#4705)
  • NODE-6065: throw MongoRuntimeError instead of MissingDependencyError in crypto connection (#4711)
  • NODE-6584: improve typing for filepaths in AutoEncryptionOptions (#4341)
  • NODE-6334: rename PoolRequstedRetry to PoolRequestedRetry (#4696)
  • NODE-7174: drop support for Node16 and Node18 (#4668)
  • NODE-7047: use custom credential provider first after URI (#4656)
  • NODE-6988: require aws sdk for aws auth (#4659)
  • NODE-5545: remove deprecated objects (#4704) (cfbada6)
Non-breaking
  • NODE-4243: drop collection checks ns not found (#4742) (a8d7c5f)
  • NODE-7223: run checkout on connect regardless of credentials (#4715) (c5f74ab)
  • NODE-7232: only send endSessions during client close if the topology supports sessions (#4722) (cc85ebf)
  • NODE-7067: Wrap socket write in a try/catch to ensure errors can be properly wrapped (#4759) (66c18b7)
View originalPermalink
How v7.0.0 went

v6.21.0

Deprecated 4
  • MongoCredentials.authMechanismProperties.AWS_SESSION_TOKEN will be removed in v7.0.0
  • CommandOptions.noResponse will be removed in v7.0.0
  • ConnectionOptions.cancellationToken will be removed in v7.0.0
  • CursorStreamOptions will be removed in v7.0.0

From MongoDB Node.js Driver

6.21.0 (2025-11-05)

The MongoDB Node.js team is pleased to announce version 6.21.0 of the mongodb package!

Release Notes
Deprecated items to be removed in 7.0.0

The following items have been deprecated and will be removed in 7.0.0:

MongoCredentials.authMechanismProperties.AWS_SESSION_TOKEN // URI & client options for AWS variables will no longer be respected
CommandOptions.noResponse // Unused
ConnectionOptions.cancellationToken // Unused
CursorStreamOptions // Only option, transform, removed in favor of Stream#map
Features
  • NODE-7230: add deprecations of items to be removed in v7 (#4774) (5104c0f)
Documentation

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

View originalPermalink
How v6.21.0 went

v6.20.0

Added 1
  • Collection and Db objects now provide references to their associated Db and MongoClient through db and client properties
Changed 2
  • Hint is now supported with unacknowledged writes for delete, update and findAndModify commands on servers that support hint
  • MongoClient.appendMetadata() now ignores duplicate metadata instead of appending it
Fixed 2
  • ChangeStream .tryNext() now updates resumeToken to prevent duplicate change documents after resume
  • Change Streams now resume on MongoServerSelectionError instead of throwing the error
Deprecated 7
  • ServerCapabilities class is deprecated
  • ReadPreference.minWireVersion property is deprecated
  • MongoClient driverInfo option is deprecated
  • MongoClient additionalDriverInfo option is deprecated
  • MongoClient metadata option is deprecated
  • MongoClient extendedMetadata option is deprecated
  • CommandOperationOptions.retryWrites option is deprecated

From MongoDB Node.js Driver

6.20.0 (2025-09-17)

The MongoDB Node.js team is pleased to announce version 6.20.0 of the mongodb package!

Release Notes
Collection and Db objects now provide references to their Db and MongoClient
import { MongoClient } from 'mongodb';

const client = new MongoClient(process.env.MONGODB_URI);
const db = client.db('test');
assert(db.client === client); // returns the MongoClient associated with the Db object
const collection = db.collection('test');
assert(collection.db === db); // returns the Db associated with the Collection object
Hint is supported with unacknowledged writes for delete, update and findAndModify commands on servers that support hint

The driver no longer throws errors when hint is provided to unacknowledged writes for delete, update and findAndModify commands in the following circumstances:

  • No error is thrown for update commands.
  • No errors are thrown for delete and findAndModify commands on servers >=4.4.
ServerCapabilities and ReadPreference.minWireVersion are deprecated

Neither the ServerCapabilities class nor the ReadPreference.minWireVersion property were ever intended for public use and, internally, are effectively dead code with the driver's minimum supported server version being 4.2.

Driver info and metadata MongoClient options have been deprecated.

These will be made internal in a future major release:

  • driverInfo
  • additionalDriverInfo
  • metadata
  • extendedMetadata
CommandOperationOptions.retryWrites is deprecated

CommandOperationOptions.retryWrites is deprecated. This per‑command option has no effect; the Node.js driver only honors retryWrites when configured at the client level (MongoClient options) or via the connection string. Do not use this option on individual commands. There is no runtime behavior change because it was already ignored, but it will be removed in an upcoming major release and may cause type or build errors in code that references it. To control retryable writes, set retryWrites in MongoClient options or include retryWrites=true|false in the connection string.

ChangeStream .tryNext() now updates resumeToken to prevent duplicates after resume

When .tryNext() returns a change document, the driver now caches its resumeToken, aligning its behavior with .next() and the 'change' event. If .tryNext() returns null (no new changes), nothing is cached, which is unchanged from previous behavior.

Previously, .tryNext() did not update the resumeToken, so a resumable error could cause a resume from an older token and re-deliver already processed changes. With this release, resumes continue from the latest token observed via .tryNext(), preventing duplicates.

const changeStream = collection.watch([]);
while (true) {
  const change = await changeStream.tryNext(); // prior versions could return duplicates
  await scheduler.wait(1000);  // delay since tryNext() does not wait for changes
}

Applications that poll change streams with .tryNext() in non-blocking loops benefit directly. There are no API changes; if you previously tracked and passed resumeAfter or startAfter manually, you can now rely on the driver’s built-in token caching.

Huge thanks to @rkistner for bringing this bug to our attention and for sharing code to reproduce it. Huge thanks as well to @Omnicpie for investigating and implementing a fix.

Change Streams now resume on MongoServerSelectionError

When the driver encounters a MongoServerSelectionError while processing a Change Stream (e.g., due to a transient network issue or during an election), it now treats the error as resumable and attempts to resume using the latest cached resume token.

This applies to both iterator and event-emitter usage:

// Iterator form
const changeStream = collection.watch([]);
for await (const change of changeStream) {
  // process change
}
// Event-emitter form
const changeStream = collection.watch([]);
changeStream.on('change', (change) => {
  // process change
});

There are no API changes. If you previously caught MongoServerSelectionError and implemented manual resume logic, you can now rely on the driver’s built-in resume mechanism, which uses the cached resume token from the change event’s _id to continue without losing events.

Huge thanks to @grossbart for bringing this bug to our attention, investigating it and for sharing code to reproduce it!

MongoClient.appendMetadata() ignores duplicate metadata

MongoClient.appendMetadata() will no longer append metadata if it duplicates the metadata already appended to the MongoClient.

Features
  • NODE-7125: add db and client properties to collection and database objects (#4640) (3469f86)
  • NODE-7134: allow hint with unacknowledged writes for delete, update and findAndModify commands (#4647) (82d6ce6)
  • NODE-7139: remove pre-4.2 logic and deprecate dead code (#4657) (14303bc)
  • NODE-7140: deprecate driver info options (#4654) (b813c85)
  • NODE-7157: deprecate retryWrites in CommandOperationOptions (#4661) (620972d)
Bug Fixes
  • NODE-4763: cache resumeToken in ChangeStream.tryNext() (#4636) (8331a93)
  • NODE-6858: treat MongoServerSelectionError as a resumable error for Change Streams (#4653) (c6d64e7)
  • NODE-7138: prevent duplicate metadata from being appended to handshake metadata (#4651) (05c230c)
Documentation

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

View originalPermalink
How v6.20.0 went

v6.19.0

Added 2
  • Support queryable encryption text field prefix, suffix and substring queries
  • Allow secureContext option in KMS TLS options for auto encryption and client encryption
Changed 3
  • findOne command now always sets limit to 1 and singleBatch to true
  • find command sets limit to batchSize + 1 when both options are equal to avoid leaving cursors open
  • MongoClient no longer sends ping command on connect when authentication is enabled, instead checks out a connection from the pool to force initial handshake
Deprecated 1
  • limit, noCursorResponse and batchSize options in findOne and find commands

From MongoDB Node.js Driver

6.19.0 (2025-08-26)

The MongoDB Node.js team is pleased to announce version 6.19.0 of the mongodb package!

Release Notes
Experimental Support for Queryable Encryption Text Field Prefix, Suffix and Substring Queries

[!IMPORTANT] Substring, prefix and suffix search are in preview and should be used for experimental workloads only. These features are unstable and their security is not guaranteed until released as Generally Available (GA). The GA version of these features may not be backwards compatible with the preview version.

When using Queryable Encryption with both automatic encryption and explicit encryption, text fields can now be queried using prefix, suffix and substring queries. This feature requires mongodb-client-encryption@>=6.5.0.

Allow a secureContext for Auto Encryption and Client Encryption TLS options

This can be provided in the tlsOptions option both both objects.

import * as tls from 'tls';
import { ClientEncryption, MongoClient } from 'mongodb';

const caFile = await fs.readFile(process.env.CSFLE_TLS_CA_FILE);
const certFile = await fs.readFile(process.env.CSFLE_TLS_CLIENT_CERT_FILE);
const secureContextOptions = {
  ca: caFile,
  key: certFile,
  cert: certFile
};
const options = {
  keyVaultNamespace: 'db.coll',
  kmsProviders: {
    aws: {}
    }
  },
  tlsOptions: {
    aws: {
      secureContext: tls.createSecureContext(secureContextOptions),
    }
  }
};

const client = this.configuration.newClient({}, { autoEncryption: { ...options, schemaMap } });
const clientEncryption = new ClientEncryption(client, options);
collection.findOne() and collection.find() will no longer potentially leave open cursors on the server

The findOne command will now always set the limit option to 1 and singleBatch to true. The limit, noCursorResponse and batchSize options have also been deprecated, and the command will guarantee no more cursors can be orphaned and no killCursors command will be potentially executed.

find will now set limit to batchSize + 1 when both options were equal, to avoid leaving cursors open.

Clients no longer send a ping on connect

When authentication is enabled, the MongoClient will no longer send a ping command when connecting since it is unnecessary. Instead it will check a connection out of the pool to force the initial handshake, and check it back in.

Features
  • NODE-4179: allow secureContext in KMS TLS options (#4578) (0ea6eaa)
  • NODE-6472: findOne and find no longer keep open cursors (#4580) (be7f808)
  • NODE-7020: remove ping on connect (#4607) (3d296b7)
  • NODE-7059, NODE-7008: add support for text queries for QE string fields (#4597) (e4492f3)
Documentation

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

View originalPermalink
How v6.19.0 went
View all

Discussion

If you publish MongoDB Node.js Driver, you can claim this product by proving you administer its repository.