Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 0 additions & 68 deletions EXPERIMENTAL_FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ This file documents all experimental features in the MongoDB Node.js Driver.
| --------------------------------------------------- | -------------------------------------------- | ------------- |
| [Runtime Adapters](#runtime-adapters) | Custom runtime module implementations | v7.2.0 |
| [AbortSignal Support](#abortsignal-support) | Cancel operations using `AbortController` | v6.13.0 |
| [Timeout Management](#timeout-management) | Control operation timeouts with `timeoutMS` | v6.6.0 |
| [Strict TypeScript Types](#strict-typescript-types) | Enhanced type safety for filters and updates | v5.0.0 |

---
Expand Down Expand Up @@ -82,73 +81,6 @@ await collection.find({}, { signal }).toArray();

---

### Timeout Management

Specifies the Client-side operations timeout (CSOT) in milliseconds after which an operation will throw an error. `timeoutMS` can be configured at the client, database, collection, session, transaction, and per-operation levels, with narrower scopes overriding broader ones.

_See [Limit Server Execution Time](https://www.mongodb.com/docs/drivers/node/current/connect/connection-options/csot/) for the full inheritance/override rules, cursor-specific behavior, Client Encryption interactions, and code examples._

> [!NOTE]
> This feature will remain experimental while the common driver specification for Client-Side Operations Timeout isn't finalized.

#### Cursor Timeout Modes

This configures how the CSOT `timeoutMS` above is applied to cursors.

**Type**: [`CursorTimeoutMode`](https://github.com/search?q=repo%3Amongodb%2Fnode-mongodb-native+path%3Aabstract_cursor.ts+CursorTimeoutMode&type=code)

**Available on**:

- [`AbstractCursorOptions.timeoutMode`](https://github.com/search?q=repo%3Amongodb%2Fnode-mongodb-native+symbol%3A%2F%5EAbstractCursorOptions%24%2F&type=code)
- [`RunCursorCommandOptions.timeoutMode`](https://github.com/search?q=repo%3Amongodb%2Fnode-mongodb-native+symbol%3A%2F%5ERunCursorCommandOptions%24%2F&type=code)

**Values**:

- `'cursorLifetime'` — Timeout applies to the entire cursor lifetime (default for non-tailable cursors)
- `'iteration'` — Timeout applies to each `cursor.next()` call (default for tailable cursors)

**Example**:

```typescript
// timeoutMS applies to each next() call, not the whole cursor
const cursor = collection.find(
{},
{
timeoutMS: 1_000,
timeoutMode: 'iteration'
}
);

for await (const doc of cursor) {
// each iteration gets its own 1s budget
}
```

#### GridFS Streams

Applies the CSOT `timeoutMS` above to GridFS upload and download streams as a per-stream lifetime.

**Options**:

- [`GridFSBucketReadStreamOptions.timeoutMS`](https://github.com/search?q=repo%3Amongodb%2Fnode-mongodb-native+symbol%3A%2F%5EGridFSBucketReadStreamOptions%24%2F&type=code) — Limits the lifetime of a download stream; if any async operation is in progress when the timeout expires, the stream throws a timeout error.
- [`GridFSBucketWriteStreamOptions.timeoutMS`](https://github.com/search?q=repo%3Amongodb%2Fnode-mongodb-native+symbol%3A%2F%5EGridFSBucketWriteStreamOptions%24%2F&type=code) — Limits the lifetime of an upload stream.

**Example**:

```typescript
const bucket = new GridFSBucket(db);

// Upload stream: fail if the whole upload takes longer than 30s
const uploadStream = bucket.openUploadStream('report.pdf', { timeoutMS: 30_000 });
await pipeline(fs.createReadStream('report.pdf'), uploadStream);

// Download stream: fail if the whole download takes longer than 10s
const downloadStream = bucket.openDownloadStream(uploadStream.id, { timeoutMS: 10_000 });
await pipeline(downloadStream, fs.createWriteStream('out.pdf'));
```

---

### Strict TypeScript Types

Provides stricter type checking for MongoDB operations with better TypeScript inference for nested paths and type safety.
Expand Down
Loading