What changed in MongoDB Node.js Driver from 6 to 7

8 releases numbered after v6.21.0 up to and including v7.6.0, stable releases only. v6.21.0 and v7.6.0 are the newest stable releases of 6 and 7 we track; this page follows them as new ones ship.

56 changes across 8 releases

Added 10

v7.6.0

  • Add kmsConnectCallback option to route KMS requests through an HTTP proxy for CSFLE and Queryable Encryption
  • Add baseBackoffMS support and update client backpressure backoff configuration

v7.5.0

  • Support for Queryable Encryption string queries in MongoDB 9.0 with exact and range-style string matching against encrypted fields

v7.2.0

  • 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

v7.0.0

  • Native support for explicit resource management with Symbol.asyncDispose implementations on MongoClient, ClientSession, ChangeStream and cursors
Changed 31

v7.6.0

  • Improve performance for MongoDB 9.0's Intelligent Workload Management by only retrying overload errors when expected to improve server conditions
  • Optimize bulk writes to serialize each document only once instead of processing twice, reducing BSON-encoding CPU usage and event-loop blocking

v7.5.0

  • TextOpts API is replaced with StringOpts
  • TextPreview algorithm is replaced with String

v7.4.0

  • 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

v7.3.0

  • Bump maxWireVersion to 29 in preparation for MongoDB LTS v9.0

v7.2.0

  • 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

v7.1.0

  • 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()
  • Replace process.nextTick() with queueMicrotask()
  • withTransaction now applies exponential backoff during transaction retries
  • Server selection deprioritizes servers during retries
  • OIDC authentication now supports hosts matching *.mongo.com in its default ALLOWED_HOSTS list

v7.0.0

  • 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
  • Updated compatibility for @aws-sdk/credential-providers to ^3.806.0, gcp-metadata to ^7.0.1, and socks to ^2.8.6
  • @aws-sdk/credential-providers is now required for MONGODB-AWS authentication
  • Custom AWS credential provider via AWS_CREDENTIAL_PROVIDER takes highest precedence over other AWS auth methods
  • Dropping a collection returns false instead of throwing when namespace not found
  • Aggregate with write concern and explain now throws MongoServerError instead of client-side error
Fixed 10

v7.6.0

  • Fix ReferenceError: require is not defined when bundling the driver into ESM by using dynamic import for the os module

v7.5.0

  • MongoClient.close() now closes checked-out connections on all servers in replica sets and sharded clusters

v7.3.0

  • 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

v7.1.1

  • 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

v7.1.0

  • 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

v7.0.0

  • All encryption-related errors now subclass MongoError
  • Fixed typo in error label from PoolRequstedRetry to PoolRequestedRetry
Removed 3

v7.6.0

  • Support for MongoDB 4.2 or less is removed; the driver will throw an error when connecting to these server versions

v7.1.0

  • aws4 package is no longer required for AWS authentication

v7.0.0

  • Explicitly provided credentials no longer accepted with MONGODB-AWS authentication in connection strings
Deprecated 2

v7.5.0

  • prefixPreview, suffixPreview, and substringPreview query types are deprecated and will be removed in a future release

v7.1.0

  • RenameCollectionOptions.new_collection option is deprecated and will be removed in a future major release

Original release notes, newest first

The list above is our reading of these notes; the originals from MongoDB are here, one fold per release.

v7.6.0
7.6.0 (2026-08-21)

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

Release Notes
Support for MongoDB 4.2 is removed

[!WARNING] When the driver connects to a MongoDB server of version 4.2 or less, it will now throw an error.

HTTP proxy support for KMS requests in CSFLE and Queryable Encryption

In-use encryption can now route KMS requests through an HTTP proxy. Set kmsConnectCallback on your ClientEncryption or auto-encryption options to control how the driver connects to a KMS host. The callback receives the target host and port and returns a connected socket (for example, a tunnel opened with HTTP CONNECT); the driver then performs the KMS TLS handshake over that socket using the provider's configured TLS options. This unblocks CSFLE and Queryable Encryption in environments that require an HTTP forward proxy for outbound KMS traffic, which the existing SOCKS5 proxyOptions does not cover.

const clientEncryption = new ClientEncryption(keyVaultClient, {
  keyVaultNamespace,
  kmsProviders,
  // Establish the KMS connection through your HTTP proxy; the driver adds TLS.
  kmsConnectCallback: ({ host, port }) => connectThroughHttpProxy(host, port)
});
Improved Intelligent Workload Management

Improved performance for MongoDB 9.0's Intelligent Workload Management (IWM) by only retrying overload errors when doing so is expected to not worsen server conditions

Bundling the driver into ESM no longer throws ReferenceError: require is not defined

v7.2.0 introduced the experimental runtimeAdapters option and, as part of it, replaced the driver’s static import of Node’s os module with a runtime require('os'). That works in a CommonJS build, but when the driver is bundled into ESM output (e.g. a Vite/esbuild/rollup server build with "type": "module"), there is no require in module scope, so constructing a client threw ReferenceError: require is not defined. The driver now loads the default os adapter through a dynamic import() that survives bundling, so new MongoClient() works in ESM bundles. CommonJS usage is unchanged, and supplying your own runtimeAdapters.os continues to work.

Bulk writes serialize each document only once

insertMany and bulkWrite previously processed each document twice - once to measure its size for batch splitting (a full recursive walk via calculateObjectSize) and again to serialize it into the command sent to the server. Documents are now serialized a single time and the resulting bytes are reused for both, decreasing the BSON-encoding CPU spent on bulk writes and reducing event-loop blocking during large batches. The improvement is most noticeable with high document counts and documents that have many fields.

Features
  • NODE-7546: add HTTP Proxy support for QE & CSFLE (#5007) (3366c21)
  • NODE-7547: bump minimum support server/wire versions to '4.4' & '9' respectively (#4994) (3d97028)
  • NODE-7624: support baseBackoffMS and update client backpressure backoff (#5020) (560837b)
Bug Fixes
  • NODE-7603: emit dynamic import('os') via tsconfig (#4992) (52f5e61)
Performance Improvements
  • NODE-7660: serialize bulk write documents a single time (#4999) (1217aa1)
Documentation

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

View originalPermalink

v7.5.0
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

v7.4.0
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

v7.3.0

[!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

v7.2.0
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

v7.1.1
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

v7.1.0
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

v7.0.0
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