This report documents all experimental features in the MongoDB Node.js Driver version 7.1.0. The driver contains 31 experimental annotations across 9 major feature categories. These features are marked as experimental because they may undergo breaking changes in future releases, even in minor or patch versions.
| Feature | Description | Introduced in | Status |
|---|---|---|---|
| Explicit Resource Management | Automatic cleanup using Symbol.asyncDispose |
v6.9.0 | |
| AbortSignal Support | Cancel operations using AbortController |
v6.13.0 | |
| Timeout Management | Control operation timeouts with timeoutMS |
v6.6.0 | |
| Cursor Timeout Modes | Configure how timeouts apply to cursors | v6.11.0 | |
| Strict TypeScript Types | Enhanced type safety for filters and updates | v5.0.0 | |
| Client-Side Encryption Features | Custom key material and rewrap APIs | v6.0.0 | |
| Queryable Encryption Text Search | Text search on encrypted fields | v6.19.0 | |
| Encrypted Fields | Schema for encrypted collections | v4.6.0 | |
| GridFS Timeout Support | Timeout options for GridFS streams | v6.6.0 |
Status:
Description: Native support for JavaScript's explicit resource management using Symbol.asyncDispose. This feature enables automatic cleanup of resources using the await using syntax.
Available On:
MongoClient- src/mongo_client.ts:466ClientSession- src/sessions.ts:293ChangeStream- src/change_stream.ts:576- All cursor types (
AbstractCursor,FindCursor,AggregationCursor, etc.) - src/cursor/abstract_cursor.ts:433
Example:
// Automatic cleanup when scope exits
await using client = new MongoClient(url);
await using session = client.startSession();
// No need to call client.close() or session.endSession()References:
- TC39 Explicit Resource Management Proposal
- Driver upgrade notes:
etc/notes/CHANGES_7.0.0.md
Stability Note: Will remain experimental until the TC39 proposal is finalized.
Status:
Type: Abortable
Source: src/mongo_types.ts:488
Description: Allows using AbortController to abort asynchronous operations. The signal.reason value is used as the error thrown.
Example:
const controller = new AbortController();
const { signal } = controller;
// Abort operation after 5 seconds
setTimeout(() => controller.abort(new Error('Operation timeout')), 5000);
await collection.find({}, { signal }).toArray();Status:
Option: timeoutMS
Description: Specifies the time (in milliseconds) an operation will run until it throws a timeout error.
Available On:
CommandOperationOptions- src/db.ts:97ClientSessionOptions- src/sessions.ts:141ClientSessionStartOptions.defaultTimeoutMS- src/sessions.ts:63ClientEncryptionOptions- src/client-side-encryption/client_encryption.ts:942MongoClientOptions- src/mongo_client.ts:145RunCommandOptions- src/operations/run_command.ts:19RunCursorCommandOptions- src/cursor/run_command_cursor.ts:23CollectionOptions- src/collection.ts:123OperationOptions- src/operations/operation.ts:42GridFSBucketReadStreamOptions- src/gridfs/index.ts:42GridFSBucketWriteStreamOptions- src/gridfs/upload.ts:36- Various database and collection operation options
Example:
// Set timeout at client level
const client = new MongoClient(url, { timeoutMS: 10000 });
// Set timeout at operation level
await collection.find({}, { timeoutMS: 5000 }).toArray();
// Set timeout for session
const session = client.startSession({ timeoutMS: 30000 });Status:
Type: CursorTimeoutMode
Source:
- Constant definition - src/cursor/abstract_cursor.ts:70
- Type definition - src/cursor/abstract_cursor.ts:104
- Option in
AbstractCursorOptions- src/cursor/abstract_cursor.ts:155 - Option in
RunCursorCommandOptions- src/cursor/run_command_cursor.ts:31
Values:
'cursorLifetime'- Timeout applies to the entire cursor lifetime'iteration'- Timeout applies to eachcursor.next()call
Description: Specifies how timeoutMS is applied to cursors.
Default Behavior:
- Non-tailable cursors:
'cursorLifetime' - Tailable cursors:
'iteration'(since tailable cursors can have arbitrarily long lifetimes)
Examples:
// Iteration mode: Each next() call must complete within 100ms
const cursor1 = collection.find({}, {
timeoutMS: 100,
timeoutMode: 'iteration'
});
for await (const doc of cursor1) {
// Process doc - each iteration has 100ms timeout
}
// Cursor lifetime mode: Entire operation must complete within 1000ms
const cursor2 = collection.find({}, {
timeoutMS: 1000,
timeoutMode: 'cursorLifetime'
});
const docs = await cursor2.toArray(); // Must complete in 1000ms totalStatus:
Description: Provides stricter type checking for MongoDB operations with better TypeScript inference for nested paths and type safety.
Types:
Source: src/mongo_types.ts:622
Provides strict type checking for filter predicates with proper nested path support.
Source: src/mongo_types.ts:664
Ensures type-safe matching of keys and values in update operations.
Source: src/mongo_types.ts:634
Provides strict typing for update operators ($set, $inc, $push, etc.).
Example:
interface User {
name: string;
age: number;
address: {
city: string;
zip: number;
};
}
const collection: Collection<User> = db.collection('users');
// Type-safe filter with nested paths
const filter: StrictFilter<User> = {
'address.city': 'New York' // ✓ Valid
// 'address.city': 123 // ✗ Compile error: number not assignable to string
};
// Type-safe update
const update: StrictUpdateFilter<User> = {
$set: { age: 30 }, // ✓ Valid
// $set: { age: 'thirty' } // ✗ Compile error
};Status:
Description: Advanced client-side encryption capabilities for enhanced data security.
Option: keyMaterial
Type: Buffer | Binary
Location: ClientEncryptionCreateDataKeyProviderOptions
Source: src/client-side-encryption/client_encryption.ts:1099
Description: Allows providing custom key material when creating data keys, giving more control over the encryption key generation process.
Example:
const encryption = new ClientEncryption(client, {
keyVaultNamespace: 'encryption.__keyVault',
kmsProviders: { local: { key: localMasterKey } }
});
const dataKeyId = await encryption.createDataKey('local', {
keyMaterial: customKeyBuffer // Experimental option
});Interfaces:
ClientEncryptionRewrapManyDataKeyProviderOptions- src/client-side-encryption/client_encryption.ts:889ClientEncryptionRewrapManyDataKeyResult- src/client-side-encryption/client_encryption.ts:1108
Description: Experimental API for rewrapping multiple data keys in a single operation, useful for key rotation scenarios.
Interface Definition:
interface ClientEncryptionRewrapManyDataKeyProviderOptions {
provider: ClientEncryptionDataKeyProvider;
masterKey?: AWSEncryptionKeyOptions | AzureEncryptionKeyOptions |
GCPEncryptionKeyOptions | KMIPEncryptionKeyOptions | undefined;
}
interface ClientEncryptionRewrapManyDataKeyResult {
/** The result of rewrapping data keys. If unset, no keys matched the filter. */
bulkWriteResult?: BulkWriteResult;
}Status:
Option: textOptions
Type: TextQueryOptions
Location: ClientEncryptionEncryptOptions
Source:
- Option in
ClientEncryptionEncryptOptions- src/client-side-encryption/client_encryption.ts:846 - Interface
TextQueryOptions- src/client-side-encryption/client_encryption.ts:855
Description: Options for Queryable Encryption fields supporting text queries. Only valid when the encryption algorithm is set to TextPreview.
Example:
const encrypted = await encryption.encrypt(value, {
algorithm: 'TextPreview',
keyId: dataKeyId,
textOptions: {
// Text search configuration options
}
});textPreview algorithm and related options are experimental and may break at any time. Not recommended for production use.
Status:
Option: encryptedFields
Type: Document
Available On:
CreateCollectionOptions- src/operations/create_collection.ts:98DropCollectionOptions- src/operations/drop.ts:15
Description: Specifies the schema for encrypted fields in a collection, used with Queryable Encryption.
Example:
// Create collection with encrypted fields
await db.createCollection('users', {
encryptedFields: {
fields: [
{
path: 'ssn',
bsonType: 'string',
keyId: dataKeyId
}
]
}
});
// Drop collection with encrypted fields
await db.dropCollection('users', {
encryptedFields: encryptedFieldsConfig
});Status:
Description: Timeout support for GridFS read and write streams.
Option: timeoutMS in GridFSBucketReadStreamOptions
Source: src/gridfs/index.ts:42
Description: Specifies the lifetime duration of a GridFS read stream. If any async operations are in progress when this timeout expires, the stream will throw a timeout error.
Example:
const bucket = new GridFSBucket(db);
const downloadStream = bucket.openDownloadStream(fileId, {
timeoutMS: 30000 // 30 second timeout for the entire download
});Option: timeoutMS in GridFSBucketWriteStreamOptions
Source: src/gridfs/upload.ts:36
Description: Specifies the time an upload operation will run until it throws a timeout error.
Example:
const bucket = new GridFSBucket(db);
const uploadStream = bucket.openUploadStream('filename.txt', {
timeoutMS: 60000 // 60 second timeout for the entire upload
});