Skip to content

Commit 50b8328

Browse files
committed
deprecate legacy timeout options; add logic to prefer timeoutMS
1 parent 4fd4b24 commit 50b8328

15 files changed

+73
-38
lines changed

src/connection_string.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,7 @@ export const OPTIONS = {
10921092
type: 'string'
10931093
},
10941094
socketTimeoutMS: {
1095+
deprecated: 'Please use timeoutMS instead',
10951096
default: 0,
10961097
type: 'uint'
10971098
},
@@ -1162,6 +1163,7 @@ export const OPTIONS = {
11621163
}
11631164
},
11641165
waitQueueTimeoutMS: {
1166+
deprecated: 'Please use timeoutMS instead',
11651167
default: 0,
11661168
type: 'uint'
11671169
},

src/cursor/abstract_cursor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export interface AbstractCursorOptions extends BSONSerializeOptions {
8484
/**
8585
* When applicable `maxTimeMS` controls the amount of time the initial command
8686
* that constructs a cursor should take. (ex. find, aggregate, listCollections)
87+
* @deprecated Will be removed in the next major version. Please use timeoutMS instead.
8788
*/
8889
maxTimeMS?: number;
8990
/**
@@ -721,6 +722,7 @@ export abstract class AbstractCursor<
721722
* Set a maxTimeMS on the cursor query, allowing for hard timeout limits on queries (Only supported on MongoDB 2.6 or higher)
722723
*
723724
* @param value - Number of milliseconds to wait before aborting the query.
725+
* @deprecated Will be removed in the next major version. Please use the timeoutMS option instead.
724726
*/
725727
maxTimeMS(value: number): this {
726728
this.throwIfInitialized();

src/cursor/find_cursor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ export class FindCursor<TSchema = any> extends ExplainableCursor<TSchema> {
333333
* Set a maxTimeMS on the cursor query, allowing for hard timeout limits on queries (Only supported on MongoDB 2.6 or higher)
334334
*
335335
* @param value - Number of milliseconds to wait before aborting the query.
336+
*@deprecated Will be removed in the next major version. Please use timeoutMS instead.
336337
*/
337338
override maxTimeMS(value: number): this {
338339
this.throwIfInitialized();

src/cursor/run_command_cursor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class RunCommandCursor extends AbstractCursor {
4848
/**
4949
* Controls the `getMore.maxTimeMS` field. Only valid when cursor is tailable await
5050
* @param maxTimeMS - the number of milliseconds to wait for new data
51+
* @deprecated Will be removed in the next major version. Please use timeoutMS instead.
5152
*/
5253
public setMaxTimeMS(maxTimeMS: number): this {
5354
this.getMoreOptions.maxAwaitTimeMS = maxTimeMS;
@@ -56,7 +57,7 @@ export class RunCommandCursor extends AbstractCursor {
5657

5758
/**
5859
* Controls the `getMore.batchSize` field
59-
* @param maxTimeMS - the number documents to return in the `nextBatch`
60+
* @param batchSize - the number documents to return in the `nextBatch`
6061
*/
6162
public setBatchSize(batchSize: number): this {
6263
this.getMoreOptions.batchSize = batchSize;
@@ -82,7 +83,8 @@ export class RunCommandCursor extends AbstractCursor {
8283
);
8384
}
8485

85-
/** Unsupported for RunCommandCursor: maxTimeMS must be configured directly on command document */
86+
/** Unsupported for RunCommandCursor: maxTimeMS must be configured directly on command document
87+
* @deprecated Will be removed in the next major version. */
8688
public override maxTimeMS(_: number): never {
8789
throw new MongoAPIError(
8890
'maxTimeMS must be configured on the command document directly, to configure getMore.maxTimeMS use cursor.setMaxTimeMS()'

src/explain.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export type ExplainVerbosityLike = ExplainVerbosity | boolean;
2424
export interface ExplainCommandOptions {
2525
/** The explain verbosity for the command. */
2626
verbosity: ExplainVerbosity;
27-
/** The maxTimeMS setting for the command. */
27+
/** The maxTimeMS setting for the command.
28+
* @deprecated Will be removed in the next major version. Please use timeoutMS instead.*/
2829
maxTimeMS?: number;
2930
}
3031

src/mongo_client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeC
152152
tlsInsecure?: boolean;
153153
/** The time in milliseconds to attempt a connection before timing out. */
154154
connectTimeoutMS?: number;
155-
/** The time in milliseconds to attempt a send or receive on a socket before the attempt times out. */
155+
/** The time in milliseconds to attempt a send or receive on a socket before the attempt times out.
156+
* @deprecated Will be removed in the next major version. Please use timeoutMS instead */
156157
socketTimeoutMS?: number;
157158
/** An array or comma-delimited string of compressors to enable network compression for communication between this client and a mongod/mongos instance. */
158159
compressors?: CompressorName[] | string;
@@ -176,7 +177,8 @@ export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeC
176177
maxConnecting?: number;
177178
/** The maximum number of milliseconds that a connection can remain idle in the pool before being removed and closed. */
178179
maxIdleTimeMS?: number;
179-
/** The maximum time in milliseconds that a thread can wait for a connection to become available. */
180+
/** The maximum time in milliseconds that a thread can wait for a connection to become available.
181+
* @deprecated Will be removed in the next major version. Please use timeoutMS instead */
180182
waitQueueTimeoutMS?: number;
181183
/** Specify a read concern for the collection (only MongoDB 3.2 or higher supported) */
182184
readConcern?: ReadConcernLike;

src/operations/aggregate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export interface AggregateOptions extends Omit<CommandOperationOptions, 'explain
2626
bypassDocumentValidation?: boolean;
2727
/** Return the query as cursor, on 2.6 \> it returns as a real cursor on pre 2.6 it returns as an emulated cursor. */
2828
cursor?: Document;
29-
/** specifies a cumulative time limit in milliseconds for processing operations on the cursor. MongoDB interrupts the operation at the earliest following interrupt point. */
29+
/** specifies a cumulative time limit in milliseconds for processing operations on the cursor. MongoDB interrupts the operation at the earliest following interrupt point.
30+
* @deprecated Will be removed in the next major version. Please use timeoutMS instead.*/
3031
maxTimeMS?: number;
3132
/** The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. */
3233
maxAwaitTimeMS?: number;

src/operations/command.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export interface CommandOperationOptions
4040
readConcern?: ReadConcernLike;
4141
/** Collation */
4242
collation?: CollationOptions;
43+
/**
44+
* @deprecated Will be removed in the next major version. Please use timeoutMS instead. */
4345
maxTimeMS?: number;
4446
/**
4547
* Comment to apply to the operation.

src/operations/count.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export interface CountOptions extends CommandOperationOptions {
1313
skip?: number;
1414
/** The maximum amounts to count before aborting. */
1515
limit?: number;
16-
/** Number of milliseconds to wait before aborting the query. */
16+
/** Number of milliseconds to wait before aborting the query.
17+
* @deprecated Will be removed in the next major version. Please use timeoutMS instead. */
1718
maxTimeMS?: number;
1819
/** An index name hint for the query. */
1920
hint?: string | Document;

src/operations/estimated_document_count.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface EstimatedDocumentCountOptions extends CommandOperationOptions {
1212
* The maximum amount of time to allow the operation to run.
1313
*
1414
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
15+
*@deprecated Will be removed in the next major version. Please use timeoutMS instead.
1516
*/
1617
maxTimeMS?: number;
1718
}

0 commit comments

Comments
 (0)