NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #3169 most downloaded on npm
The official MongoDB driver for Node.js
Last release today
04 Oct 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
195 versions withdrawn
withdrawn after publishing
15 years old
922 releases · first in 2011
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.
With the v3.1.0 release we officially deprecated the 2.x driver. With this release that driver is effectively EOL, and will no longer be supported. Pl…
The MongoDB Node.js team is pleased to announce version 3.2.1 of the driver.
Due to a publishing snafu v3.2.1 was immediately published without a proper v3.2.0 release
<h2>Release Highlights</h2>
<h3>2.x EOL</h3> With the v3.1.0 release we officially deprecated the 2.x driver. With this release that driver is effectively EOL, and will no longer be supported. Please update your driver as soon as possible.
<h3>Unified Topology</h3>
In this release we are very excited to announce the immediate availability of a complete rewrite of the driver's "topology" layer. This is the core brains of the driver responsible for things like server selection, server discovery and monitoring. This work combines the three existing topology concepts (Mongos, ReplSet, and Server) into a single type Topology. The new Topology type uses the same machinery to represent all three types, greatly improving our ability to maintain the code, and reducing the chance for bug duplication.
The Topology class no longer uses a callback store, instead relying on a server selection loop for operation execution. This means failed operations will fail faster, with more accurate stack traces and specifics about the failure. It generally makes it much easier to reason about what the driver is doing each time an operation is executed.
You can enable it with the useUnifiedTopology feature flag passed to your MongoClient constructor, like so:
const client = MongoClient('mongodb://localhost:27017', { useUnifiedTopology: true });
This topology layer will replace the existing topologies in a breaking 4.x release later this year, so we strongly encourage our users to try it out as soon as possible.
<h3>withTransaction helper</h3>
Reliably committing a transaction in the face of errors can be a complicated endeavor using the MongoDB 4.0 drivers API. This version introduces a withTransaction helper method on the ClientSession object that allows application logic to be executed within a transaction. This method is capable of retrying either the commit operation or entire transaction as needed (and when the error permits) to better ensure that the transaction can complete successfully. Consider using this for all but the most complicated of transactions use cases.
A call to withTransaction begins a new transaction, executes the provided function, and then attempts to commit the transaction. The function passed to withTransaction must take a session parameter, and this session must be passed to all methods within the function. If some error is encountered, it will attempt to re-commit the transaction before ultimately failing back to the user after aborting the transaction.
NOTE: A mentioned, the passed in function MAY be retried multiple times, please keep this in mind when executing non-database operations within the function.
Here’s an example of it in action:
const client = new MongoClient();
await client.connect();
const session = client.startSession();
// NOTE: the `withTransaction` method only supports functions that return a `Promise`
try {
await session.withTransaction(async function(session) {
const coll = client.db('foo').collection('coll');
await coll.insertOne({ a: 42 }, { session });
});
} catch (err) {
// transaction failed after attempted retry
console.dir({ err });
}
<h3>Cursors support asyncInterator and for..await..of loops</h3>
Symbol.asyncIterator is defined on cursors for Node.js versions that support it (>=v10.x.x). This allows you to use for..await..of loops with cursors:
client.connect().then(async function() {
const collection = client.db(‘test’).collection(‘asyncIterators’);
const cursor = collection.find();
for await(const doc of cursor) {
console.log(item);
}
});
<h3>OP_MSG</h3> This release also brings support for a new wire protocol introduced originally in version 3.6 of the server.
<h3>Database-level aggregation</h3>
The server supports several collection-less aggregation source stages like $currentOp and $listLocalSessions. In this version we have added a Db.prototype.aggregate helper for database-level aggregations.
<h3>Authentication</h3>
Since the 3.6 server release, multiple authentication contexts for a single MongoClient have been prohibited. This release cleans up the final bits of internal api related to multiple auth contexts, and greatly improves our ability to maintain this code. This not only involved simplifying the implementation of our auth providers, but also a large refactor of how connections are established and handshaked. Calls to auth and logout are now no-ops, and top level API for this will be removed in the next major release.
<h2>Release Notes</h2> <h3>Bug</h3> <ul> <li>[<a href='https://jira.mongodb.org/browse/NODE-1534'>NODE-1534</a>] - retryWrites=true, remove, and limit=0 </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1658'>NODE-1658</a>] - Fix normalizing option names coming from connection string </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1685'>NODE-1685</a>] - SCRAM-SHA-256 tests are not actually run against replicaset </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1687'>NODE-1687</a>] - Replicaset tests for core use Server and require primary on port 31000 </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1736'>NODE-1736</a>] - Explain useNewUrlParser </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1778'>NODE-1778</a>] - BulkWrite: Incorrect batch-size calculations causes batch to fail </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1782'>NODE-1782</a>] - New Topology layer fails to clear monitor on close </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1840'>NODE-1840</a>] - useNewUrlParser: true causes "command find requires authentication" </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1874'>NODE-1874</a>] - Wrong JavaScript const use in lib/operations/db_ops.js </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1876'>NODE-1876</a>] - Uncatchable exceptions </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1898'>NODE-1898</a>] - BulkWrite: Incorrect batch-size calculations when array contains object with undefined value </li> </ul>
<h3>New Feature</h3> <ul> <li>[<a href='https://jira.mongodb.org/browse/NODE-1085'>NODE-1085</a>] - OP_MSG support </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1259'>NODE-1259</a>] - Refactor mongodb-core to use a single Topology type </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1684'>NODE-1684</a>] - Define [Symbol.iterator] on our Cursor objects </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1741'>NODE-1741</a>] - Implement Convenient API for Transactions </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1783'>NODE-1783</a>] - Support running commands as aggregation </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1792'>NODE-1792</a>] - Update handling of write concern errors by user management commands </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1793'>NODE-1793</a>] - Transaction test runner should use "local" read concern when asserting the final collection state </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1841'>NODE-1841</a>] - Disable TLS renegotiation when possible </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1850'>NODE-1850</a>] - Drivers should ignore batchSize=0 for aggregate with $out </li> <li>[<a href='https://jira.mongodb.org/browse/NODE-1879'>NODE-1879</a>] - Resync transaction spec tests for bulk write error reporting change </li> </ul>
<h3>Improvement</h3>
<ul>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1264'>NODE-1264</a>] - provide pre-built binaries for kerberos and ext-bson using node-pre-gyp
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1291'>NODE-1291</a>] - Integrate single Topology from Core into Native
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1334'>NODE-1334</a>] - Remove mutation of user-owned objects
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1385'>NODE-1385</a>] - Remove JSDOC that says [param=null]
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1435'>NODE-1435</a>] - Remove unnecessary auth code from connection pool
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1436'>NODE-1436</a>] - Remove duplicated code from auth providers
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1437'>NODE-1437</a>] - Implement auth connection string tests
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1442'>NODE-1442</a>] - Refactor Auth to exclusively use a MongoCredential object
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1453'>NODE-1453</a>] - Resync SDAM tests
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1491'>NODE-1491</a>] - Add option for applications to register a custom server selector
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1620'>NODE-1620</a>] - Port authentication support to new Topology class
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1644'>NODE-1644</a>] - Deprecate parallelCollectionScan helpers
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1674'>NODE-1674</a>] - Fix auth workflow with regards to auth mechanism resolution
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1683'>NODE-1683</a>] - Evaluate and correct monitoring in new SDAM layer
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1688'>NODE-1688</a>] - Update atlas connectivity tests to use new auth credentials
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1731'>NODE-1731</a>] - CI Test against Node 10.x (Dubnium)
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1732'>NODE-1732</a>] - Update Travis version of MongoDB
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1823'>NODE-1823</a>] - Update unified topology to use refactored wire protocol
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1830'>NODE-1830</a>] - Reduce creation of OP_QUERY to wire protocol classes
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1845'>NODE-1845</a>] - Allow Connection to be shared with mock server
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1859'>NODE-1859</a>] - Remove dead authentication code in pool and topologies
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1860'>NODE-1860</a>] - Ensure ssl is honored when provided in URI
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1863'>NODE-1863</a>] - Move connection handshake logic out of Server topology class
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1888'>NODE-1888</a>] - countDocuments should use group with _id: 1
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1890'>NODE-1890</a>] - Do not run sharding transaction tests for mongodb < 4.1.5
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1892'>NODE-1892</a>] - Move all command modifying sessions methods out of pool
</li>
<li>[<a href='https://jira.mongodb.org/browse/NODE-1895'>NODE-1895</a>] - Refactor insertMany to remove resultMutator
</li>
</ul>
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
NODE-1043 URI-escaping authentication and hostname details in connection string
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
allow auth option in MongoClient.connect
promoteLongs from MongoClient's connectadd appname to list of valid option names
appname to list of valid option namesNODE-1039 ensure we force destroy server instances, forcing queue to be flushed.
NODE-1019 Set keepAlive to 300 seconds or 1/2 of socketTimeout if socketTimeout < keepAlive.
NODE-985 Deprecated Db.authenticate and Admin.authenticate and moved auth methods into authenticate.js to ensure MongoClient.connect does not print de…
_id (Issue #1517, https://github.com/vkarpov15).Mark group and profilingInfo as deprecated methods
Don't rely on global toString() for checking if object (Issue #1494, https://github.com/vkarpov15).
NODE-935, NODE-931 Make MongoClient strict options validation optional and instead print annoying console.warn entries.
NODE-925 ensure we reschedule operations while pool is < poolSize while pool is growing and there are no connections with not currently performing wor
NODE-919 ReplicaSet connection does not close immediately (Issue #156).
NODE-908 Keep auth contexts in replset and mongos topology to ensure correct application of authentication credentials when primary is first server to
Updated mongodb-core to 2.1.5 to include bson 1.0.4 and bson-ext 1.0.4 due to Buffer.from being broken in early node 4.x versions.
* Corrupted Npm release fix.
Updated mongodb-core to 2.1.4 to fix bson ObjectId toString issue with utils.inspect messing with toString parameters in node 6.
updated createCollection doc options and linked to create command.
NODE-899 reversed upsertedId change to bring back old behavior.
Delay topologyMonitoring on successful attemptReconnect as no need to run a full scan immediately.
Your coding agent can read these notes before it upgrades. Set up the MCP server →