Skip to content

Releases: mongodb/node-mongodb-native

v3.3.0

13 Aug 19:22
Compare
Choose a tag to compare

The MongoDB Node.js team is pleased to announce version 3.3.0 of the driver

Release Highlights

Server Version 4.2 feature support

This latest release brings support for features in the newly released MongoDB v4.2:

  • Distributed Transactions
  • On-Demand Materialized Views with the $merge operator
  • Wildcard Indexes
  • Retryable Reads
  • MongoDB Query Language Enhancements.

SRV Polling for Sharded Clusters

The Driver has supported connecting to a cluster using an SRV record since version 3.0. Prior to now, we would only resolve the SRV record when initially connecting. This was fine for single replica sets, as the driver is able to discover new members added after initial connect from any member of a replica set. However, in a sharded deployment, individual mongos processes do not have an awareness of each other. This means that if the deployment changes in a shared cluster, the driver would have no way of knowing without disconnecting and connecting with a new client.

Starting in 3.3, if a driver connects to a sharded cluster with an SRV record, we will now periodically check that SRV record for any changes in the deployment, and update the client-side connections accordingly.

**NOTE: This feature is only available when starting a client with { useUnifiedTopology: true } **

Beta support for MongoDB Client-Side Encryption

The driver now has support for MongoDB Client-Side Encryption. This requires installing the mongodb-client-encryption npm package in your project.

Merged mongodb-core into node-mongodb-native

Up until this release, the mongodb driver has consisted of two components:

  • mongodb-core: The low-level engine of the driver.
  • node-mongodb-native: The API layer of the driver, published as mongodb

Over time, this separation has done more harm than good, and has led to increased development time for repairing bugs and implementing new features. Starting in the 3.3 release of mongodb, we have merged mongodb-core into node-mongodb-native, removing this barrier to development.

Release Notes

Bug

  • [NODE-1480] - 'Should handle Error thrown during operation' in error_tests.js should handle exception
  • [NODE-1994] - fix 'should correctly handle multiple unordered batch API'
  • [NODE-2022] - startAtOperationTime and resumeToken conflict on cursor restarts
  • [NODE-2051] - MongoClient with autoEncryption does not clean up MongoCryptD client
  • [NODE-2054] - [FLE] AutoEncrypter MongoClient does not use new url parser
  • [NODE-2060] - can't use database named 'constructor'
  • [NODE-2067] - requestid overflow
  • [NODE-2075] - Ensure error events also emit close events in change_stream.js
  • [NODE-2077] - Invalid staleness calculation

Epic

New Feature

  • [NODE-1740] - Implement Unified URI Options
  • [NODE-1745] - Support polling SRV records for mongos discovery
  • [NODE-1750] - Connections survive primary stepdown
  • [NODE-1766] - Aggregate command must be sent to a primary if it uses $out
  • [NODE-1820] - Resync CRUD spec tests to use transaction spec test format
  • [NODE-1824] - Support 'startAfter' option to the $changeStream stage
  • [NODE-1864] - Support Retryable Writes on by Default
  • [NODE-1866] - Support postBatchResumeToken in change streams
  • [NODE-1880] - Add support for majority read concern level to Aggregation $out
  • [NODE-1896] - Implement executeOperationV2
  • [NODE-1902] - Add "aspects" to all operation classes
  • [NODE-1920] - Add the ability to specify a pipeline to an update command
  • [NODE-1931] - Ensure 4.0 drivers return an error when attempting sharded transactions on 4.2
  • [NODE-1965] - More useful error when bulk writes fail
  • [NODE-2023] - set default for useRecoveryToken to true
  • [NODE-2071] - [FLE]: use crypto callbacks
  • [NODE-2078] - Improve error message for missing `mongodb-client-encryption`
  • [NODE-2095] - Operating System Removals/Updates for 4.2
  • [NODE-2098] - Raise an actionable error message when retryWrites fails due to using an unsupported storage engine
  • [NODE-2102] - Mark the FLE feature as "Beta" in driver docs

Task

  • [NODE-1854] - POC - Support Client-side Field Level Encryption
  • [NODE-1949] - Add tests for postBatchResumeToken support
  • [NODE-1950] - Test writes in transactions do not send writeConcern when collection write concern is w=0
  • [NODE-1951] - Amend change stream missing resume token tests for wire version 8+
  • [NODE-1966] - Merge core and native modules into a single driver
  • [NODE-1979] - Clarify resume token used in resuming and getResumeToken
  • [NODE-2004] - Spec: Finer-grained updates from aggregation via $merge
  • [NODE-2017] - Fix result assertion in change stream spec test

Improvement

  • [NODE-1425] - validate internal representation of `ReadPreference`
  • [NODE-1557] - Clean up constructor for ClientSession
  • [NODE-1682] - Implement connection pool reset
  • [NODE-1756] - applyWriteConcern should take a writeConcern
  • [NODE-1811] - Refactor readconcern tests
  • [NODE-1897] - Move all operations to their own classes
  • [NODE-1910] - Refactor findAnd* operations to extend findAndModify
  • [NODE-1943] - Move executeOperation to executeLegacyOperation
  • [NODE-1944] - Use new CommandOperation for operations
  • [NODE-1947] - create a `MongoNamespace` for database and...
Read more

v3.2.1

21 Mar 20:13
Compare
Choose a tag to compare

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

Release Highlights

2.x EOL

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.

Unified Topology

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.

`withTransaction` helper

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 });
}

Cursors support asyncInterator and for..await..of loops

`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);
  }
});

OP_MSG

This release also brings support for a new wire protocol introduced originally in version 3.6 of the server.

Database-level aggregation

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.

Authentication

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.

Release Notes

Bug

  • [NODE-1534] - retryWrites=true, remove, and limit=0
  • [NODE-1658] - Fix normalizing option names coming from connection string
  • [NODE-1685] - SCRAM-SHA-256 tests are not actually run against replicaset
  • [NODE-1687] - Replicaset tests for core use Server and require primary on port 31000
  • [NODE-1736] - Explain useNewUrlParser
  • [NODE-1778] - BulkWrite: Incorrect batch-size calculations causes batch to fail
  • [NODE-1782] - New Topology layer fails to clear monitor on close
  • [NODE-1840] - useNewUrlParser: true causes "command find requires authentication"
  • [NODE-1874] - Wrong JavaScript const use in lib/operations/db_ops.js
  • [NODE-1876] - Uncatchable exceptions
  • [NODE-1898] - BulkWrite: Incorrect batch-size calculations when array contains object with undefined value

New Feature

  • [NODE-1085] - OP_MSG support
  • [NODE-1259] - Refactor mongodb-core to use a single Topology type
  • [NODE-1684] - Define [Symbol.iterator] on our Cursor objects
  • [NODE-1741] - Implement Convenient API for Transactions
  • [NODE-1783] - Support running commands as aggregation
  • [NODE-1792] - Update handling of write concern errors by user management commands
  • [NODE-1793] - Transaction test runner should use "local" read concern when asserting the final collection state
  • [NODE-1841] - Disable TLS renegotiation when possible
  • [NODE-1850] - Drivers should ignore batchSize=0 for aggregate with $out
  • [NODE-1879] - Resync transaction spec tests for bulk write error reporting change

Improvement

  • [NODE-1264] - provide pre-built binaries for kerberos and ext-bson using node-pre-gyp
  • [NODE-1291] - Integrate single `Topology` from Core into Native
  • [NODE-1334] - Remove mutation of user-owned objects
  • [NODE-1385] - Remove JSDOC that says [param=null]
  • [NODE-1435] - Remove unnecessary auth code from connection pool
  • [NODE-1436] - Remove duplicated code from auth providers
  • [NODE-1437] - Implement auth connection string tests
  • [NODE-1442] - Refactor Auth to exclusively use a MongoCredential object
  • [NODE-1453] - Resync SDAM tests
  • [NODE-1491] - Add option for applications to register a custom server selector
  • [NODE-1620] - Port authentication support to new Topology class
  • [NODE-1644] - Deprecate parallelCollectionScan helpers
  • [NODE-1674] - Fix auth workflow with regards to auth mechanism resolution
  • [NODE-1683] - Evaluate and correct monitoring in new SDAM layer
  • [NODE-1688] - Update atlas ...
Read more

V2.0.44

28 Sep 11:34
Compare
Choose a tag to compare

2.0.44 09-28-2015

  • Bug fixes for APM upconverting of legacy INSERT/UPDATE/REMOVE wire protocol messages.
  • NODE-562, fixed issue where a Replicaset MongoDB URI with a single seed and replSet name set would cause a single direct connection instead of topology discovery.
  • Updated mongodb-core to 1.2.14.
  • NODE-563 Introduced options.ignoreUndefined for db class and MongoClient db options, made serialize undefined to null default again but allowing for overrides on insert/update/delete operations.
  • Use handleCallback if result is an error for count queries. (Issue #1298, https://github.com/agclever)
  • Rewind cursor to correctly force reconnect on capped collections when first query comes back empty.
  • NODE-571 added code 59 to legacy server errors when SCRAM-SHA-1 mechanism fails.
  • NODE-572 Remove examples that use the second parameter to find().

V2.0.43

17 Sep 07:42
Compare
Choose a tag to compare
  • Propagate timeout event correctly to db instances.
  • Application Monitoring API (APM) implemented.
  • NOT providing replSet name in MongoClient connection URI will force single server connection. Fixes issue where it was impossible to directly connect to a replicaset member server.
  • Updated mongodb-core to 1.2.12.
  • NODE-541 Initial Support "read committed" isolation level where "committed" means confimed by the voting majority of a replica set.
  • GridStore doesn't share readPreference setting from connection string. (Issue #1295, https://github.com/zhangyaoxing)
  • fixed forceServerObjectId calls (Issue #1292, https://github.com/d-mon-)
  • Pass promise library through to DB function (Issue #1294, https://github.com/RovingCodeMonkey)