Skip to content

Commit a35fa91

Browse files
committed
chore: fixes
1 parent 14abcb2 commit a35fa91

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

src/cursor/abstract_cursor.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export type CursorFlag = (typeof CURSOR_FLAGS)[number];
6363

6464
/**
6565
* @public
66+
* @experimental
6667
* Specifies how `timeoutMS` is applied to the cursor. Can be either `'cursorLifeTime'` or `'iteration'`
6768
* When set to `'iteration'`, the deadline specified by `timeoutMS` applies to each call of
6869
* `cursor.next()`.
@@ -74,7 +75,6 @@ export type CursorFlag = (typeof CURSOR_FLAGS)[number];
7475
* definition can have an arbitrarily long lifetime.
7576
*
7677
* @example
77-
* # Example showing use of `'iteration'`
7878
* ```ts
7979
* const cursor = collection.find({}, {timeoutMS: 100, timeoutMode: 'iteration'});
8080
* for await (const doc of cursor) {
@@ -84,8 +84,7 @@ export type CursorFlag = (typeof CURSOR_FLAGS)[number];
8484
* }
8585
* ```
8686
*
87-
* # Example showing use of `'cursorLifetime'`
88-
*
87+
* @example
8988
* ```ts
9089
* const cursor = collection.find({}, { timeoutMS: 1000, timeoutMode: 'cursorLifetime' });
9190
* const docs = await cursor.toArray(); // This entire line will throw a timeout error if all batches are not fetched and returned within 1000ms.
@@ -146,13 +145,17 @@ export interface AbstractCursorOptions extends BSONSerializeOptions {
146145
/** Specifies the time an operation will run until it throws a timeout error. See {@link AbstractCursorOptions.timeoutMode} for more details on how this option applies to cursors. */
147146
timeoutMS?: number;
148147
/**
148+
* @public
149+
* @experimental
149150
* Specifies how `timeoutMS` is applied to the cursor. Can be either `'cursorLifeTime'` or `'iteration'`
150151
* When set to `'iteration'`, the deadline specified by `timeoutMS` applies to each call of
151152
* `cursor.next()`.
152153
* When set to `'cursorLifetime'`, the deadline applies to the life of the entire cursor.
153154
*
154-
* Note that the use of '`cursorLifetime`' should be limited to relatively short-lived cursors as
155-
* it has the potential to hang on an operation for the entirety of `timeoutMS`.
155+
* Depending on the type of cursor being used, this option has different default values.
156+
* For non-tailable cursors, this value defaults to `'cursorLifetime'`
157+
* For tailable cursors, this value defaults to `'iteration'` since tailable cursors, by
158+
* definition can have an arbitrarily long lifetime.
156159
*
157160
* @example
158161
* ```ts
@@ -167,7 +170,7 @@ export interface AbstractCursorOptions extends BSONSerializeOptions {
167170
* @example
168171
* ```ts
169172
* const cursor = collection.find({}, { timeoutMS: 1000, timeoutMode: 'cursorLifetime' });
170-
* const docs = await cursor.toArray(); // This line will throw a timeout error if all batches are not fetched and returned within 1000ms.
173+
* const docs = await cursor.toArray(); // This entire line will throw a timeout error if all batches are not fetched and returned within 1000ms.
171174
* ```
172175
*/
173176
timeoutMode?: CursorTimeoutMode;

src/cursor/run_command_cursor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export type RunCursorCommandOptions = {
2727
timeoutMS?: number;
2828
/**
2929
* @public
30+
* @experimental
3031
* Specifies how `timeoutMS` is applied to the cursor. Can be either `'cursorLifeTime'` or `'iteration'`
3132
* When set to `'iteration'`, the deadline specified by `timeoutMS` applies to each call of
3233
* `cursor.next()`.
@@ -43,7 +44,7 @@ export type RunCursorCommandOptions = {
4344
* for await (const doc of cursor) {
4445
* // process doc
4546
* // This will throw a timeout error if any of the iterator's `next()` calls takes more than 100ms, but
46-
* will continue to iterate successfully otherwise, regardless of the number of batches.
47+
* // will continue to iterate successfully otherwise, regardless of the number of batches.
4748
* }
4849
* ```
4950
*

src/db.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export class Db {
222222
return this.s.namespace.toString();
223223
}
224224

225-
get timeoutMS(): number | undefined {
225+
public get timeoutMS(): number | undefined {
226226
return this.s.options?.timeoutMS;
227227
}
228228

src/operations/operation.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ export abstract class AbstractOperation<TResult = any> {
6161

6262
options: OperationOptions;
6363

64-
/** TODO(NODE-6197): remove dead code */
65-
timeout?: Timeout;
6664
/** Specifies the time an operation will run until it throws a timeout error. */
6765
timeoutMS?: number;
6866

0 commit comments

Comments
 (0)