unstale

npm / mongodb

mongodb

What changed in mongodb 4 to 7, from its official release notes, upgrade guides and advisories. Also covers @types/mongodb. Sources checked 2026-11-30.

152 breaking1 security11 deprecations16 new APIs and options1 performance28 behavior and defaults1 tooling22 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli on npm

mongodb 7110 changes

Breaking changes 58

  • When unset on MongoClient, the driver no longer forces true, allowing the runtime process default to apply; explicit driver options still take precedence.

    7.9.0release notes

  • Only NamespaceNotFound server errors are swallowed; all other errors are thrown.

    7.9.0release notes

  • Construction now fails when ENVIRONMENT and OIDC_CALLBACK or OIDC_HUMAN_CALLBACK are provided in any combination, preventing the associated OIDC bearer token leak.

    7.9.0release notes

  • For unordered bulk writes mixing inserts with updates or deletes, insertedIds is now keyed by each insert's operation index rather than a running insert count.

    7.8.0release notes

  • In the three-argument overload, index options are passed to the server as written, enabling newer server options without driver allow-list updates; invalid options are no longer filtered.

    7.8.0release notes

  • Its return type is now ClientEncryptionRewrapManyDataKeyResult instead of an anonymous type; runtime behavior is unchanged.

    7.8.0release notes

  • timeoutMS and timeoutMode are deprecated no-ops: operations no longer time out because of them. Use the per-stage timeout options instead.

    7.8.0release notes

  • The driver no longer supports MongoDB 4.2 or older servers and throws an error when connecting to them.

    7.6.0release notes

  • Closing a client now closes checked-out connections across all servers, interrupting in-flight operations promptly.

    7.5.0release notes

  • String replaces the TextPreview algorithm for Queryable Encryption string queries.

    7.5.0release notes

  • StringOpts replaces TextOpts for Queryable Encryption string queries.

    7.5.0release notes

  • On replica sets, server deprioritization is restricted to overload errors.

    7.2.0release notes

  • Wildcard matching now requires full subdomain or path matches, preventing partial suffix matches from being accepted.

    7.1.1release notes

  • Aggregate with write concern and explain now throws a MongoServerError instead of throwing client-side.

    7.0.0release notes

  • TypeScript now restricts the filename to the default crypt_shared library name or a path ending in that filename.

    7.0.0release notes

  • TypeScript now restricts the filename to the default mongocryptd name or a path ending in that filename.

    7.0.0release notes

  • This package is now required for MONGODB-AWS authentication.

    7.0.0release notes

  • The beta namespace was removed; resource management moved into the driver.

    7.0.0release notes

  • The deprecated CancellationToken type has been removed.

    7.0.0release notes

  • The deprecated ClientMetadataOptions type has been removed.

    7.0.0release notes

  • The deprecated transaction property has been removed from ClientSession.

    7.0.0release notes

  • The deprecated CloseOptions type has been removed.

    7.0.0release notes

  • retryWrites has been removed from CommandOperationOptions; it is a global MongoClient option.

    7.0.0release notes

  • The noResponse option has been removed; it was never intended for public APIs and did not work properly.

    7.0.0release notes

  • This internal ClientMetadata property is no longer exposed in the public API.

    7.0.0release notes

  • This internal ClientMetadata property is no longer exposed in the public API.

    7.0.0release notes

  • The deprecated autoIndexId option has been removed.

    7.0.0release notes

  • Dropping a collection returns false instead of throwing when the namespace is not found.

    7.0.0release notes

  • The deprecated batchSize option has been removed from FindOneOptions.

    7.0.0release notes

  • The deprecated limit option has been removed from FindOneOptions.

    7.0.0release notes

  • The deprecated noCursorTimeout option has been removed from FindOneOptions.

    7.0.0release notes

  • FindOptions no longer accepts a generic type parameter.

    7.0.0release notes

  • Cursors no longer set a default batchSize of 1000 for getMore; it is set only when explicitly configured for the cursor.

    7.0.0release notes

  • The deprecated aliases option has been removed.

    7.0.0release notes

  • The deprecated contentType option has been removed.

    7.0.0release notes

  • The deprecated aliases property has been removed.

    7.0.0release notes

  • The deprecated contentType property has been removed.

    7.0.0release notes

  • The optional peer dependency minimum version is 7.0.0; support for version 2.x is dropped.

    7.0.0release notes

  • connect now runs a handshake regardless of whether credentials are defined, making fail-fast precondition checks more consistent across environments.

    7.0.0release notes

  • This internal ClientMetadata property is no longer exposed in the public API.

    7.0.0release notes

  • This internal ClientMetadata property is no longer exposed in the public API.

    7.0.0release notes

  • This internal ClientMetadata property is no longer exposed in the public API.

    7.0.0release notes

  • The deprecated useNewUrlParser option has been removed.

    7.0.0release notes

  • The deprecated useUnifiedTopology option has been removed.

    7.0.0release notes

  • The driver now uses bson@7.0.0; BSON functionality re-exported from the driver is subject to the BSON V7 release-note changes.

    7.0.0release notes

  • Explicit credentials in the URI or options are no longer accepted; AWS credentials are fetched through the required AWS SDK.

    7.0.0release notes

  • The optional peer dependency minimum version is raised to 7.0.0, dropping support for 6.x.

    7.0.0release notes

  • The unsupported MONGODB-CR authentication mechanism has been removed.

    7.0.0release notes

  • The optional peer dependency minimum version is 7.0.0; support for versions 1.x and 2.x is dropped.

    7.0.0release notes

  • This internal ClientMetadata property is no longer exposed in the public API.

    7.0.0release notes

  • This internal ClientMetadata property is no longer exposed in the public API.

    7.0.0release notes

  • This internal ClientMetadata property is no longer exposed in the public API.

    7.0.0release notes

  • The deprecated minWireVersion property has been removed.

    7.0.0release notes

  • The deprecated ResumeOptions type has been removed.

    7.0.0release notes

  • The deprecated ServerCapabilities type has been removed.

    7.0.0release notes

  • Cursor and ChangeStream stream() no longer accepts a transform function; ReadableStream.map() can be used instead.

    7.0.0release notes

  • MongoClient, ClientSession, ChangeStream, and cursors implement Symbol.asyncDispose for explicit resource management; this support is experimental.

    7.0.0release notes

  • The deprecated Transaction type has been removed.

    7.0.0release notes

Security 1

  • SRV host names are checked in normalized form, addressing a host-name verification security issue and allowing case-different connection-string host names to connect.

    7.8.0release notes

Deprecations 5

  • SelectServerOptions is deprecated because it is not intended for public use and will become internal in the next major release.

    7.9.0release notes

  • The prefixPreview query type is deprecated and will be removed in a future release.

    7.5.0release notes

  • The substringPreview query type is deprecated and will be removed in a future release.

    7.5.0release notes

  • The suffixPreview query type is deprecated and will be removed in a future release.

    7.5.0release notes

  • The unused new_collection option is deprecated and can be safely removed with no behavioral change.

    7.1.0release notes

New APIs and options 10

  • Adds a three-argument overload separating index options from createIndexes command options; the existing two-parameter overload remains supported for now.

    7.8.0release notes

  • Adds a host name suffix constraint for every host returned by an SRV lookup; it can be configured on the client or in the connection string.

    7.8.0release notes

  • Adds a synchronous client option that decides whether a host returned by an SRV lookup may be used; it must return a boolean.

    7.8.0release notes

  • Support was added for baseBackoffMS alongside an update to client backpressure backoff.

    7.6.0release notes

  • Set this callback on ClientEncryption or auto-encryption options to connect to KMS hosts through an HTTP proxy; the driver performs the KMS TLS handshake over the returned socket.

    7.6.0release notes

  • Returns the number of documents remaining in the change stream from the last batch, allowing callers to check for buffered documents before invoking async methods.

    7.2.0release notes

  • The token bucket is optional in client backpressure.

    7.2.0release notes

  • When enabled, the driver deprioritizes servers that return overload errors during retry server selection; defaults to false.

    7.2.0release notes

  • Configures the maximum number of retries during server overload; defaults to 2, and 0 disables overload retries.

    7.2.0release notes

  • Experimental MongoClient option for injecting core Node.js APIs, including the os module, for alternative runtimes or restricted environments.

    7.2.0release notes

Performance 1

  • insertMany and bulkWrite serialize each document once and reuse the resulting bytes for batch sizing and commands, reducing BSON-encoding CPU and event-loop blocking.

    7.6.0release notes

Behavior and default changes 23

  • The @experimental tag was removed from this feature, which is no longer experimental.

    7.8.0release notes

  • The @experimental tag was removed from this feature, which is no longer experimental.

    7.8.0release notes

  • The @experimental tag was removed from this feature, which is no longer experimental.

    7.8.0release notes

  • The @experimental tag was removed from this feature, which is no longer experimental.

    7.8.0release notes

  • The @experimental tag was removed from this feature, which is no longer experimental.

    7.8.0release notes

  • hello and isMaster commands on monitoring connections are never compressed, even when compressors are configured.

    7.8.0release notes

  • Uses Node.js' built-in zstd implementation when available, so Node.js 22.15.0+ no longer requires @mongodb-js/zstd; older Node.js versions continue to use that package.

    7.8.0release notes

  • The driver retries overload errors only when a retry is expected not to worsen server conditions, improving performance for MongoDB 9.0's Intelligent Workload Management.

    7.6.0release notes

  • The prefix query type is now generally available for Queryable Encryption string queries.

    7.5.0release notes

  • The substring query type is now generally available for Queryable Encryption string queries.

    7.5.0release notes

  • The suffix query type is now generally available for Queryable Encryption string queries.

    7.5.0release notes

  • The async disposal methods on MongoClient, ClientSession, ChangeStream, and cursors are now officially supported, enabling await using for automatic cleanup without experimental flags.

    7.4.0release notes

  • The maximum wire version and maximum server version were bumped to 29 in preparation for MongoDB LTS (v9.0).

    7.3.0release notes

  • Retry loops use exponential backoff and jitter.

    7.2.0release notes

  • The driver uses standard Uint8Array APIs and globalThis.crypto instead of Node-specific Buffer and crypto APIs, improving compatibility with non-Node.js runtimes.

    7.2.0release notes

  • The default OIDC allowed-host list now supports hosts matching *.mongo.com.

    7.1.0release notes

  • The driver replaces Node-specific APIs with standards-based equivalents and explicitly imports node:process, improving compatibility with alternate runtimes.

    7.1.0release notes

  • Connection establishment failures no longer clear the pool, preventing unnecessary connection churn when server-side connection rate limiting rejects requests.

    7.1.0release notes

  • When retrying a command, server selection deprioritizes servers to improve stability and reduce repeated targeting of overloaded or previously failed servers.

    7.1.0release notes

  • A custom AWS credential provider now takes the highest precedence over other AWS authentication methods.

    7.0.0release notes

  • Change streams no longer filter $changeStream stage options, allowing options to reach the server even before they are in public type definitions.

    7.0.0release notes

  • close only attempts session cleanup when the topology supports sessions.

    7.0.0release notes

  • Errors thrown during encryption are now subclasses of MongoError.

    7.0.0release notes

Fixes and other changes 12

  • The single-parameter overload is no longer deprecated; the overload mixing command and index options remains deprecated, and a separate-options overload is not deprecated.

    7.9.0release notes

  • A $meta sort direction in [field, direction] form now works consistently with the object and nested-array forms.

    7.8.0release notes

  • GridFS download, delete, rename, and upload abort queries now match file IDs with $eq; command monitoring and logs show the explicit operator.

    7.8.0release notes

  • A failed OIDC token fetch now affects only the operation that triggered it; later operations can attempt a new token fetch without restarting the process.

    7.7.0release notes

  • The default os adapter now loads through dynamic import, so constructing a MongoClient in bundled ESM output no longer throws ReferenceError: require is not defined.

    7.6.0release notes

  • Write operations in causally consistent sessions now include readConcern.afterClusterTime, maintaining the “read your own writes” guarantee across primary failovers in sharded clusters.

    7.4.0release notes

  • Explicit UTF-8 string conversion fixes SCRAM authentication in non-Node.js environments such as Deno and other web-compatible runtimes.

    7.3.0release notes

  • The driver now applies TCP keep-alive and no-delay settings after TLS socket creation, preventing settings from being silently ignored.

    7.1.1release notes

  • OIDC reauthentication now succeeds when MongoClient is configured with promoteValues: false.

    7.1.0release notes

  • Aggregations using $merge or $out now respect secondary and secondaryPreferred read preferences instead of forcing execution on the primary.

    7.1.0release notes

  • The options parameter is now correctly marked optional in the TypeScript definition.

    7.0.0release notes

  • The PoolClearedError error label typo is fixed from PoolRequstedRetry to PoolRequestedRetry.

    7.0.0release notes

mongodb 676 changes

Breaking changes 62

  • timeoutMode is deprecated and has no effect starting in this release.

    6.22.0release notes

  • timeoutMS is deprecated and has no effect; operations no longer time out because of it. Use per-stage timeouts instead.

    6.22.0release notes

  • The transform option is deprecated and removed in favor of Stream#map; CursorStreamOptions will be removed in 7.0.0.

    6.21.0release notes

  • The addUser API is removed.

    6.0.0upgrade guiderelease notes

  • The options interface associated with the removed addUser APIs has also been removed.

    6.0.0release notes

  • The deprecated API has been removed; applications can send the createUser command directly.

    6.0.0release notes

  • Unsupported options are removed from admin.command.

    6.0.0upgrade guide

  • readConcern and writeConcern options are no longer handled by the driver; attach these properties to the command document instead.

    6.0.0release notes

  • AutoEncrypter is made internal.

    6.0.0upgrade guiderelease notes

  • Boolean options now accept only true and false.

    6.0.0upgrade guiderelease notes

  • The driver adopts bson v6.

    6.0.0upgrade guiderelease notes

  • Duplicate BulkWriteResult accessors are removed.

    6.0.0upgrade guide

  • The deprecated method has been removed; use insertedIds instead.

    6.0.0release notes

  • The deprecated method has been removed; use upsertedIds or getUpsertedIdAt(index) instead.

    6.0.0release notes

  • The deprecated property has been removed; use insertedCount instead.

    6.0.0release notes

  • The deprecated property has been removed; use matchedCount instead.

    6.0.0release notes

  • The deprecated property has been removed; use modifiedCount instead.

    6.0.0release notes

  • The deprecated property has been removed; use deletedCount instead.

    6.0.0release notes

  • The deprecated property has been removed; use upsertedCount instead.

    6.0.0release notes

  • Callbacks are removed from encrypt, decrypt, and createDataKey.

    6.0.0upgrade guiderelease notes

  • Callback support has been removed; asynchronous calls use promises.

    6.0.0release notes

  • A session from one client cannot be used on another.

    6.0.0upgrade guide

  • The collection.stats API is removed.

    6.0.0upgrade guiderelease notes

  • The interface associated with collection.stats has been removed.

    6.0.0release notes

  • The transaction API no longer returns the command result.

    6.0.0upgrade guiderelease notes

  • Repeated options in a connection string are validated.

    6.0.0upgrade guiderelease notes

  • Unneeded fields are removed from ConnectionPoolCreatedEvent.options.

    6.0.0upgrade guiderelease notes

  • The TypeScript return type now reflects that the method returns the DataKey's insertedId, not a DataKey.

    6.0.0release notes

  • Unsupported options are removed from db.command.

    6.0.0upgrade guide

  • readConcern and writeConcern options are no longer handled by the driver; attach these properties to the command document instead.

    6.0.0release notes

  • EvalOperation is removed.

    6.0.0upgrade guide

  • EvalOptions is removed.

    6.0.0upgrade guiderelease notes

  • This static constant has been removed because the class no longer emits its own events.

    6.0.0release notes

  • This static constant has been removed because the class no longer emits its own events.

    6.0.0release notes

  • The stream now relies on Node.js Writable methods and event handling; finish and drain no longer receive the GridFSFile document, which is available as gridFSFile on the stream.

    6.0.0release notes

  • The findOneAndX family returns only the found document or null by default; set includeResultMetadata to true to retain the previous ModifyResult behavior.

    6.0.0release notes

  • includeResultsMetadata is false by default.

    6.0.0upgrade guide

  • Deprecated keep alive options are removed.

    6.0.0upgrade guiderelease notes

  • The deprecated option has been removed; TCP keep alive is always on and set to 30000ms.

    6.0.0release notes

  • Kerberos compatibility is bumped to ^2.0.1.

    6.0.0upgrade guiderelease notes

  • MongoClient.autoEncrypter is made internal.

    6.0.0upgrade guiderelease notes

  • The driver adopts mongodb-client-encryption v6.

    6.0.0upgrade guide

  • The optional peer dependency minimum is raised to 6.0.0; useful public APIs formerly exposed by this package have moved into the driver.

    6.0.0release notes

  • mongodb-js/saslprep is added as a required dependency.

    6.0.0upgrade guide

  • MongoError is marked for internal use; Node 14 cause assignment logic is removed.

    6.0.0upgrade guide

  • Driver helpers now throw this error when given a session from a different MongoClient.

    6.0.0release notes

  • The minimum supported Node.js version was updated.

    5.0.0, 6.0.0release notesupgrade guiderelease notesupgrade guide

  • Support for onKMSProvidersRefresh is dropped.

    6.0.0upgrade guiderelease notes

  • An empty readPreferenceTags value in a connection string is now parsed as an empty tag document.

    6.0.0release notes

  • SOCKS proxy support now requires installing socks as a peer dependency; it is no longer installed automatically.

    6.0.0release notes

  • Deprecated ssl options are removed.

    6.0.0upgrade guide

  • The deprecated option has been removed; use tlsCAFile instead.

    6.0.0release notes

  • The deprecated option has been removed; use tlsCertificateKeyFile instead.

    6.0.0release notes

  • The deprecated option has been removed; use tlsCRLFile instead.

    6.0.0release notes

  • The deprecated option has been removed; use tlsCertificateKeyFile instead.

    6.0.0release notes

  • The deprecated option has been removed; use tlsCertificateKeyFilePassword instead.

    6.0.0release notes

  • The deprecated option has been removed; use tlsAllowInvalidCertificates instead.

    6.0.0release notes

  • TLS files are now read asynchronously on first connection rather than synchronously during MongoClient construction; file errors occur when connecting.

    6.0.0release notes

  • The deprecated option has been removed; use tlsCertificateKeyFile instead.

    6.0.0release notes

  • withSession returns the executor result.

    6.0.0upgrade guiderelease notes

  • withTransaction returns the executor result.

    6.0.0upgrade guiderelease notes

  • The optional peer dependency minimum is raised from 1.0.0 to 1.1.0.

    6.0.0release notes

Deprecations 6

  • noResponse is deprecated as unused and will be removed in 7.0.0.

    6.21.0release notes

  • cancellationToken is deprecated as unused and will be removed in 7.0.0.

    6.21.0release notes

  • AWS_SESSION_TOKEN is deprecated and will be removed in 7.0.0; URI and client options for AWS variables will no longer be respected.

    6.21.0release notes

  • MongoError and subclass constructors are now for internal use only and may change outside major versions.

    6.0.0release notes

  • Using useNewUrlParser emits a deprecation warning.

    6.0.0upgrade guiderelease notes

  • Using useUnifiedTopology emits a deprecation warning.

    6.0.0upgrade guiderelease notes

New APIs and options 2

Behavior and default changes 3

  • GridFSBucketWriteStream uses the implementer Writable methods.

    6.0.0upgrade guide

  • MongoCryptError is now a subclass of MongoError.

    6.0.0release notes

  • TLS files are read asynchronously.

    6.0.0upgrade guide

Fixes and other changes 3

  • The class no longer manually emits events handled by Node.js stream logic.

    6.0.0release notes

  • tlsCertificateKeyFile now maps to cert and key.

    6.0.0upgrade guide

  • The withTransaction return type is fixed.

    6.0.0upgrade guide

mongodb 533 changes

Breaking changes 30

New APIs and options 1

  • An experimental type retains strict type checking capabilities for queries that use dot notation.

    5.0.0release notes

Behavior and default changes 1

  • Strict type checking for dot-notation CRUD filters is no longer enabled by default.

    5.0.0release notes

Fixes and other changes 1

  • The driver closes a cursor when a loop exits early.

    5.0.0release notes

mongodb 413 changes

Breaking changes 2

  • Using a change stream as an iterator and an emitter concurrently now results in an error.

    4.0.0release notes

  • MD5 hashing has been removed from the GridFS API.

    4.0.0release notes

New APIs and options 3

Behavior and default changes 1

Tooling 1

  • The driver now provides first-class support for type definitions.

    4.0.0release notes

Fixes and other changes 6