diff --git a/src/connection_string.ts b/src/connection_string.ts index 82ff04ce243..74a477a0808 100644 --- a/src/connection_string.ts +++ b/src/connection_string.ts @@ -1099,6 +1099,7 @@ export const OPTIONS = { type: 'string' }, socketTimeoutMS: { + deprecated: 'Please use timeoutMS instead', default: 0, type: 'uint' }, @@ -1169,6 +1170,7 @@ export const OPTIONS = { } }, waitQueueTimeoutMS: { + deprecated: 'Please use timeoutMS instead', default: 0, type: 'uint' }, diff --git a/src/cursor/abstract_cursor.ts b/src/cursor/abstract_cursor.ts index 96d28d05584..dd3c40bfab6 100644 --- a/src/cursor/abstract_cursor.ts +++ b/src/cursor/abstract_cursor.ts @@ -84,6 +84,7 @@ export interface AbstractCursorOptions extends BSONSerializeOptions { /** * When applicable `maxTimeMS` controls the amount of time the initial command * that constructs a cursor should take. (ex. find, aggregate, listCollections) + * @deprecated Will be removed in the next major version. Please use timeoutMS instead. */ maxTimeMS?: number; /** @@ -721,6 +722,7 @@ export abstract class AbstractCursor< * Set a maxTimeMS on the cursor query, allowing for hard timeout limits on queries (Only supported on MongoDB 2.6 or higher) * * @param value - Number of milliseconds to wait before aborting the query. + * @deprecated Will be removed in the next major version. Please use the timeoutMS option instead. */ maxTimeMS(value: number): this { this.throwIfInitialized(); diff --git a/src/cursor/find_cursor.ts b/src/cursor/find_cursor.ts index 96b764dc7ff..c9a1827fa07 100644 --- a/src/cursor/find_cursor.ts +++ b/src/cursor/find_cursor.ts @@ -304,6 +304,7 @@ export class FindCursor extends AbstractCursor { * Set a maxTimeMS on the cursor query, allowing for hard timeout limits on queries (Only supported on MongoDB 2.6 or higher) * * @param value - Number of milliseconds to wait before aborting the query. + *@deprecated Will be removed in the next major version. Please use timeoutMS instead. */ override maxTimeMS(value: number): this { this.throwIfInitialized(); diff --git a/src/cursor/run_command_cursor.ts b/src/cursor/run_command_cursor.ts index 90e4a94fd42..839b5890099 100644 --- a/src/cursor/run_command_cursor.ts +++ b/src/cursor/run_command_cursor.ts @@ -48,6 +48,7 @@ export class RunCommandCursor extends AbstractCursor { /** * Controls the `getMore.maxTimeMS` field. Only valid when cursor is tailable await * @param maxTimeMS - the number of milliseconds to wait for new data + * @deprecated Will be removed in the next major version. Please use timeoutMS instead. */ public setMaxTimeMS(maxTimeMS: number): this { this.getMoreOptions.maxAwaitTimeMS = maxTimeMS; @@ -56,7 +57,7 @@ export class RunCommandCursor extends AbstractCursor { /** * Controls the `getMore.batchSize` field - * @param maxTimeMS - the number documents to return in the `nextBatch` + * @param batchSize - the number documents to return in the `nextBatch` */ public setBatchSize(batchSize: number): this { this.getMoreOptions.batchSize = batchSize; @@ -82,7 +83,8 @@ export class RunCommandCursor extends AbstractCursor { ); } - /** Unsupported for RunCommandCursor: maxTimeMS must be configured directly on command document */ + /** Unsupported for RunCommandCursor: maxTimeMS must be configured directly on command document + * @deprecated Will be removed in the next major version. */ public override maxTimeMS(_: number): never { throw new MongoAPIError( 'maxTimeMS must be configured on the command document directly, to configure getMore.maxTimeMS use cursor.setMaxTimeMS()' diff --git a/src/explain.ts b/src/explain.ts index 51f591efd47..b656c2f7304 100644 --- a/src/explain.ts +++ b/src/explain.ts @@ -20,7 +20,8 @@ export type ExplainVerbosityLike = ExplainVerbosity | boolean; export interface ExplainCommandOptions { /** The explain verbosity for the command. */ verbosity: ExplainVerbosity; - /** The maxTimeMS setting for the command. */ + /** The maxTimeMS setting for the command. + * @deprecated Will be removed in the next major version. Please use timeoutMS instead.*/ maxTimeMS?: number; } diff --git a/src/mongo_client.ts b/src/mongo_client.ts index cb66fb0bfd2..ab8496ebd18 100644 --- a/src/mongo_client.ts +++ b/src/mongo_client.ts @@ -152,7 +152,8 @@ export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeC tlsInsecure?: boolean; /** The time in milliseconds to attempt a connection before timing out. */ connectTimeoutMS?: number; - /** The time in milliseconds to attempt a send or receive on a socket before the attempt times out. */ + /** The time in milliseconds to attempt a send or receive on a socket before the attempt times out. + * @deprecated Will be removed in the next major version. Please use timeoutMS instead */ socketTimeoutMS?: number; /** An array or comma-delimited string of compressors to enable network compression for communication between this client and a mongod/mongos instance. */ compressors?: CompressorName[] | string; @@ -176,7 +177,8 @@ export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeC maxConnecting?: number; /** The maximum number of milliseconds that a connection can remain idle in the pool before being removed and closed. */ maxIdleTimeMS?: number; - /** The maximum time in milliseconds that a thread can wait for a connection to become available. */ + /** The maximum time in milliseconds that a thread can wait for a connection to become available. + * @deprecated Will be removed in the next major version. Please use timeoutMS instead */ waitQueueTimeoutMS?: number; /** Specify a read concern for the collection (only MongoDB 3.2 or higher supported) */ readConcern?: ReadConcernLike; diff --git a/src/operations/aggregate.ts b/src/operations/aggregate.ts index 0e9fbb0b846..4f05e690bdb 100644 --- a/src/operations/aggregate.ts +++ b/src/operations/aggregate.ts @@ -26,7 +26,8 @@ export interface AggregateOptions extends Omit it returns as a real cursor on pre 2.6 it returns as an emulated cursor. */ cursor?: Document; - /** specifies a cumulative time limit in milliseconds for processing operations on the cursor. MongoDB interrupts the operation at the earliest following interrupt point. */ + /** specifies a cumulative time limit in milliseconds for processing operations on the cursor. MongoDB interrupts the operation at the earliest following interrupt point. + * @deprecated Will be removed in the next major version. Please use timeoutMS instead.*/ maxTimeMS?: number; /** The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. */ maxAwaitTimeMS?: number; diff --git a/src/operations/command.ts b/src/operations/command.ts index 5bd80f796d1..010cd382057 100644 --- a/src/operations/command.ts +++ b/src/operations/command.ts @@ -40,6 +40,8 @@ export interface CommandOperationOptions readConcern?: ReadConcernLike; /** Collation */ collation?: CollationOptions; + /** + * @deprecated Will be removed in the next major version. Please use timeoutMS instead. */ maxTimeMS?: number; /** * Comment to apply to the operation. diff --git a/src/operations/count.ts b/src/operations/count.ts index 82330a11e76..da79a20e835 100644 --- a/src/operations/count.ts +++ b/src/operations/count.ts @@ -13,7 +13,8 @@ export interface CountOptions extends CommandOperationOptions { skip?: number; /** The maximum amounts to count before aborting. */ limit?: number; - /** Number of milliseconds to wait before aborting the query. */ + /** Number of milliseconds to wait before aborting the query. + * @deprecated Will be removed in the next major version. Please use timeoutMS instead. */ maxTimeMS?: number; /** An index name hint for the query. */ hint?: string | Document; diff --git a/src/operations/estimated_document_count.ts b/src/operations/estimated_document_count.ts index 5ab5aa4c305..79b58fbfe88 100644 --- a/src/operations/estimated_document_count.ts +++ b/src/operations/estimated_document_count.ts @@ -12,6 +12,7 @@ export interface EstimatedDocumentCountOptions extends CommandOperationOptions { * The maximum amount of time to allow the operation to run. * * This option is sent only if the caller explicitly provides a value. The default is to not send a value. + *@deprecated Will be removed in the next major version. Please use timeoutMS instead. */ maxTimeMS?: number; } diff --git a/src/operations/find.ts b/src/operations/find.ts index 10453d141da..df618cc432b 100644 --- a/src/operations/find.ts +++ b/src/operations/find.ts @@ -44,7 +44,8 @@ export interface FindOptions min?: Document; /** The exclusive upper bound for a specific index */ max?: Document; - /** Number of milliseconds to wait before aborting the query. */ + /** Number of milliseconds to wait before aborting the query. + * @deprecated Will be removed in the next major version. Please use timeoutMS instead. */ maxTimeMS?: number; /** The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. Requires `tailable` and `awaitData` to be true */ maxAwaitTimeMS?: number; @@ -73,7 +74,6 @@ export interface FindOptions * @deprecated This API is deprecated in favor of `collection.find().explain()`. */ explain?: ExplainOptions['explain']; - /** @internal*/ timeoutMode?: CursorTimeoutMode; } diff --git a/src/operations/get_more.ts b/src/operations/get_more.ts index 34317d533b5..d4bf84e7446 100644 --- a/src/operations/get_more.ts +++ b/src/operations/get_more.ts @@ -17,7 +17,7 @@ export interface GetMoreOptions extends OperationOptions { * getMore only supports 'comment' in server versions 4.4 and above. */ comment?: unknown; - /** Number of milliseconds to wait before aborting the query. */ + /** Number of milliseconds to wait before aborting the query. maxTimeMS?: number; /** TODO(NODE-4413): Address bug with maxAwaitTimeMS not being passed in from the cursor correctly */ maxAwaitTimeMS?: number; diff --git a/src/utils.ts b/src/utils.ts index 6146fe3995f..81d8503cb25 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -571,7 +571,6 @@ export function resolveOptions( result.timeoutMS = options?.timeoutMS ?? parent?.timeoutMS; if (result.timeoutMS != null && result.writeConcern) { const matchOptions = new Set(['wtimeout', 'wtimeoutMS']); - console.log(result.writeConcern); const writeConcernKeys = Object.keys(result.writeConcern); if (writeConcernKeys.length <= 2 && writeConcernKeys.every(k => matchOptions.has(k))) { delete result.writeConcern; diff --git a/src/write_concern.ts b/src/write_concern.ts index 390646a3be0..1406151c0d0 100644 --- a/src/write_concern.ts +++ b/src/write_concern.ts @@ -15,7 +15,8 @@ export interface WriteConcernOptions { export interface WriteConcernSettings { /** The write concern */ w?: W; - /** The write concern timeout */ + /** The write concern timeout + * @deprecated Will be removed in the next major version. Please use timeoutMS */ wtimeoutMS?: number; /** The journal write concern */ journal?: boolean; @@ -65,7 +66,8 @@ export class WriteConcern { readonly w?: W; /** Request acknowledgment that the write operation has been written to the on-disk journal */ readonly journal?: boolean; - /** Specify a time limit to prevent write operations from blocking indefinitely */ + /** Specify a time limit to prevent write operations from blocking indefinitely + * @deprecated Will be removed in the next major version. Please use timeoutMS */ readonly wtimeoutMS?: number; /** * Specify a time limit to prevent write operations from blocking indefinitely.