NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm
npm, #3169 most downloaded on npm
The official MongoDB driver for Node.js
Latest stable
7.9.0
Last release 6 days ago
16 Nov 2026
Ships on a steady schedule
a new release about every 8 days
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
15 years old
968 releases · first in 2011
Drag across the ruler to compare, or tap a release to open it.
…outside those allowlisted by the application ( CVE-2026-126835 ). Users are encouraged to upgrade to the fixed version or mitigate as soon as possible…
The MongoDB Node.js team is pleased to announce version 7.9.0 of the mongodb package!
Warning
Node Driver versions from 6.7.0 before 7.9.0 (this release) are affected by a security issue related to OIDC bearer tokens being inappropriately shared to domains outside those allowlisted by the application (CVE-2026-126835). Users are encouraged to upgrade to the fixed version or mitigate as soon as possible.
Applications that use OIDC_CALLBACK or OIDC_HUMAN_CALLBACK in affected versions can avoid this bearer token leak by refusing connection strings whose authMechanismProperties include ENVIRONMENT.
MongoClient now throws when both ENVIRONMENT and OIDC_CALLBACK / OIDC_HUMAN_CALLBACK are passed to its constructorWhen constructing a MongoClient:
ENVIRONMENT can be specified in either the connection string or the options object provided to the MongoClient constructor.OIDC_CALLBACK and OIDC_HUMAN_CALLBACK can be specified only in the options object.Now, providing an environment and a callback (in any combination of options and connection string) fails.
// Now fails:
// connection string:
// 'mongodb://example.com/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:azure,TOKEN_RESOURCE:x'
const uri = process.env.MONGODB_URI;
// throws!
const client = new MongoClient(uri, {
authMechanismProperties: {
...
// get a token for the user (e.g. browser login)
OIDC_HUMAN_CALLBACK: async params => {
return { accessToken: await getUserToken(params) };
},
...
}
});dropIndexes no longer swallows all errorsPreviously, dropIndexes swallowed almost all errors. With this change, dropIndexes will only swallow NamespaceNotFound server errors, and all other errors will be thrown as expected.
autoSelectFamily process default is now respectedWhen autoSelectFamily is not set on the MongoClient, the driver no longer forces true, so --no-network-family-autoselection and net.setDefaultAutoSelectFamily(false) now apply to its sockets. Explicit driver options still take precedence.
Warning
Runtimes other than Node.js may have a different default for autoSelectFamily. Because the driver no longer sets true itself, that runtime default now applies. There is no change on Node.js 20 and later, where the default is true.
Thanks to @aniruddhaadak80 for the initial implementation!
createIndexRecent work accidentally marked db.collection(collection).createIndex({ a: 1, b: 1 }); as deprecated.
The correct deprecation status of overloads is:
// not deprecated
db.collection(collection).createIndex({ a: 1, b: 1 });
// deprecated, removed in an upcoming major version
db.collection(collection).createIndex(
{ a: 1, b: 1 },
{/* mixed command and index options */});
// new, not deprecated
db.collection(collection).createIndex(
{ a: 1, b: 1 },
{/* index-related options */},
{/* command-related options */});SelectServerOptionsSelectServerOptions is not intended for public use and will be made internal in the next major release.
createIndex (#5106) (18f21e5)We invite you to try the mongodb library immediately, and report any issues to the NODE project.
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
…operation timeout can expose other users' data ( CVE-2026-119179 ). Users are encouraged to discontinue the use of timeoutMS as soon as possible.
The MongoDB Node.js team is pleased to announce version 7.8.0 of the mongodb package!
Warning
Node Driver versions from v6.11.0 and from v7.0.0 before v7.8.0 (this release) are affected by a security issue related to the use of the experimental timeoutMS feature where connection pool desynchronization after operation timeout can expose other users' data (CVE-2026-119179). Users are encouraged to discontinue the use of timeoutMS as soon as possible.
Warning
Node Driver versions from v3.3.3 before v7.8.0 (this release) are affected by a security issue concerning the verification of host names returned by SRV lookups, which could allow an attacker in control of the DNS response to redirect the driver to a host outside the user's domain (CVE-2026-126837). Users using SRV records are encouraged to upgrade to v7.8.0 as soon as possible.
timeoutMS is deprecated and now a no-opWarning
timeoutMS and timeoutMode are deprecated and have no effect starting in this release. They are still accepted and will not throw, but operations will no longer time out because of them. They are slated for removal in a future release.
Use the per-stage timeouts instead: serverSelectionTimeoutMS, waitQueueTimeoutMS, socketTimeoutMS, and maxTimeMS for server-side execution.
This release adds two new methods of validating DNS:
srvAllowedHostsSuffix - A host name suffix that every host returned by the SRV lookup must end with. This option can be configured on the client or the connection string.srvHostValidator - A synchronous function that decides whether a host returned by the SRV lookup may be used. This option can only be configured on the client. This function must accept a string and has to return a boolean; returning anything else, including the Promise returned by an async function, will result in an error.Warning
Modifying the default SRV domain name validation can create vulnerabilities.
SRV host names are now compared in a normalized form (case-insensitively, without a trailing dot, and with internationalized names in xn-- form). Connection strings whose SRV host name differs in case from the host names returned by DNS, such as mongodb+srv://TEST1.TEST.BUILD.10GEN.CC, previously failed SRV verification and now connect.
@mongodb-js/zstd on Node.js 22.15.0+The driver now uses Node.js' built-in zstd implementation when it is available. On older Node.js versions it continues to use @mongodb-js/zstd, so no changes are needed for existing setups.
Thanks to @axelonet for the original contribution!
Before:
// Index options and command options were on the same object
await collection.createIndex(
{ email: 1 },
{
// index options
unique: true,
name: 'email_unique',
// command options
commitQuorum: 'majority',
maxTimeMS: 5000
}
);After:
await collection.createIndex(
{ email: 1 },
// Argument 2: options that describe the index itself
{ unique: true, name: 'email_unique' },
// Argument 3: options for the createIndexes command
{ commitQuorum: 'majority', maxTimeMS: 5000 }
);Both overloads will be supported for now. In a future major release, the two parameter overload will be removed.
Before:
// The driver only forwarded options present in allow list.
// `newIndexOption` was silently dropped and never reached the server.
await collection.createIndex({ location: '2dsphere' }, { newIndexOption: true });
// But! `nonexistentIndexOption` was also removed and so the server never threw an error
await collection.createIndex({ location: '2dsphere' }, { nonexistentIndexOption: true });After:
// Index options are passed to the server as written.
// This means you can use a new option supported by the server without waiting
// for the driver to add it to an allow list!
await collection.createIndex(
{ location: '2dsphere' },
{ newIndexOption: true },
undefined
);
// But! it also means the driver will no longer prevent a bad option either
await collection.createIndex(
{ location: '2dsphere' },
{ nonexistentIndexOption: true }, // throws
undefined
);The two-parameter overload will continue to filter for valid index options. In a future major release, the two parameter overload will be removed.
@experimental tags from features which are no-longer experimentalNo-longer experimental entities:
DropCollectionOptions.encryptedFieldsCreateCollectionOptions.encryptedFieldsClientEncryptionCreateDataKeyProviderOptions.keyMaterialClientEncryptionRewrapManyDataKeyProviderOptionsClientEncryptionRewrapManyDataKeyResultAlongside these changes is also a change to the return type of rewrapManyDataKey to ClientEncryptionRewrapManyDataKeyResult from an anonymous type. This improves internal type consistency and public api clarity without changing runtime behavior.
$meta with a [field, direction] pair now worksPreviously, passing a $meta sort direction in the [field, direction] form, for example cursor.sort(['score', { $meta: 'textScore' }]), threw MongoInvalidArgumentError: Invalid sort direction. The object form ({ score: { $meta: 'textScore' } }) and the nested array form ([['score', { $meta: 'textScore' }]]) already worked, so the same sort was accepted or rejected depending on how it was written. All three forms now behave the same.
Thanks to @spokodev for the fix!
insertedIds mismatches on bulkwrites with mixed op typesFor unordered bulk writes that mixed inserts with updates or deletes, BulkWriteResult.insertedIds was keyed by a running count of inserts, not by each insert's index in the operations list. It's now keyed by the operation index, which matches ordered bulk writes and the documentation.
Thanks to @spokodev for this fix!
GridFS download, delete, rename and upload abort now query by file ID with $eq. Nothing changes for normal IDs, but you'll see { _id: { $eq: <id> } } in command monitoring and logs.
hello commands are no longer compressedWhen compressors was configured, the driver could send hello and isMaster on monitoring connections as compressed messages, which the compression specification forbids. These commands are now never compressed.
We invite you to try the mongodb library immediately, and report any issues to the NODE project.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
The MongoDB Node.js team is pleased to announce version 7.7.0 of the mongodb package!
The MongoDB Node.js team is pleased to announce version 7.7.0 of the mongodb package!
A single failed OIDC token fetch, such as a cloud metadata endpoint timing out, used to leave the driver's token-fetch mutex holding that failure. Every later operation on the affected MongoClient then failed with the original error without attempting a new token fetch, and only restarting the process restored authentication. A failed token fetch now affects only the operation that triggered it.
Dependency version changes:
bson: 7.2.0 -> 7.3.2mongodb-connection-string-url: 7.0.1 -> 7.0.2mongodb-js/saslprep: 1.4.11 -> 1.5.0We invite you to try the mongodb library immediately, and report any issues to the NODE project.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
The MongoDB Node.js team is pleased to announce version 7.6.0 of the mongodb package!
The MongoDB Node.js team is pleased to announce version 7.6.0 of the mongodb package!
Warning
When the driver connects to a MongoDB server of version 4.2 or less, it will now throw an error.
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 performance for MongoDB 9.0's Intelligent Workload Management (IWM) by only retrying overload errors when expected to not worsen server conditions.
ReferenceError: require is not definedv7.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.
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.
We invite you to try the mongodb library immediately, and report any issues to the NODE project.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.