yarn mongodb 4.12.0

latest releases: 6.10.0-dev.20241116.sha.aa986f8e, 6.10.0-dev.20241115.sha.1320ad87, 6.10.0-dev.20241113.sha.20564f7a...
2 years ago

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

Release Highlights

ChangeStreams are now AsyncIterators

ChangeStreams are now async iterables and can be used anywhere that expects an async iterable. Notably, change streams can now be used in Javascript for-await loops:

const changeStream = collection.watch();
for await (const change of changeStream) {
  console.log(“Received change: , change);
}

Some users may have been using change streams in for-await loops manually by using a for-await loop with the ChangeStream’s internal cursor. For example:

const changeStream = collection.watch();
for await (const change of changeStream.cursor) {
  console.log(“Received change: , change);
}

The change stream cursor has no support for resumabilty and consequently the change stream will never attempt to resume any errors. We strongly caution against using a change stream cursor as an async iterable and strongly recommend using the change stream directly.

Server Monitoring Fix When Monitoring Events are Skipped

Version 4.7.0 of the Node driver released an improvement to our server monitoring in FAAS environments by allowing the driver to skip monitoring events if there were more than one monitoring events in the queue when the monitoring code restarted. When skipping monitoring events that contained a topology change, the driver would incorrectly fail to update its view of the topology.

Version 4.12.0 fixes this issue by ensuring that the topology is always updated when monitoring events are processed.

Performance Improvements with Buffering

This release also modifies the data structures used internally in the driver to use linked lists in places where random access is not required and constant time insertion and deletion is beneficial.

External Contributions

Many thanks to @ImRodry for helping us fix the documentation for our deprecated callback overloads in this release!

Features

Bug Fixes

Documentation

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

Don't miss a new mongodb release

NewReleases is sending notifications on new releases.