Skip to content

Commit 54c72aa

Browse files
committed
deprecate legacy timeout options
1 parent 6686768 commit 54c72aa

File tree

14 files changed

+29
-13
lines changed

14 files changed

+29
-13
lines changed

src/connection_string.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@ export const OPTIONS = {
10991099
type: 'string'
11001100
},
11011101
socketTimeoutMS: {
1102+
deprecated: 'Please use timeoutMS instead',
11021103
default: 0,
11031104
type: 'uint'
11041105
},
@@ -1169,6 +1170,7 @@ export const OPTIONS = {
11691170
}
11701171
},
11711172
waitQueueTimeoutMS: {
1173+
deprecated: 'Please use timeoutMS instead',
11721174
default: 0,
11731175
type: 'uint'
11741176
},

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
@@ -304,6 +304,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
304304
* Set a maxTimeMS on the cursor query, allowing for hard timeout limits on queries (Only supported on MongoDB 2.6 or higher)
305305
*
306306
* @param value - Number of milliseconds to wait before aborting the query.
307+
*@deprecated Will be removed in the next major version. Please use timeoutMS instead.
307308
*/
308309
override maxTimeMS(value: number): this {
309310
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
@@ -20,7 +20,8 @@ export type ExplainVerbosityLike = ExplainVerbosity | boolean;
2020
export interface ExplainCommandOptions {
2121
/** The explain verbosity for the command. */
2222
verbosity: ExplainVerbosity;
23-
/** The maxTimeMS setting for the command. */
23+
/** The maxTimeMS setting for the command.
24+
* @deprecated Will be removed in the next major version. Please use timeoutMS instead.*/
2425
maxTimeMS?: number;
2526
}
2627

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)