Skip to content

Commit 03e42d4

Browse files
committed
chore(NODE-6493): CSOT clean ups and sync runCursorCommand test (#4309)
1 parent 22d8c17 commit 03e42d4

25 files changed

+48
-137
lines changed

etc/notes/errors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ This class should **never** be directly instantiated.
111111

112112
### `MongoOperationTimeoutError`
113113

114-
- TODO(NODE-5688): Add MongoOperationTimeoutError documentation
114+
- TODO(NODE-6491): Add MongoOperationTimeoutError documentation
115115

116116
### MongoUnexpectedServerResponseError
117117

src/change_stream.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,8 @@ export type ChangeStreamEvents<
543543
/**
544544
* @remarks Note that the `close` event is currently emitted whenever the internal `ChangeStreamCursor`
545545
* instance is closed, which can occur multiple times for a given `ChangeStream` instance.
546+
*
547+
* TODO(NODE-6434): address this issue in NODE-6434
546548
*/
547549
close(): void;
548550
};

src/connection_string.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ export const OPTIONS = {
10921092
type: 'string'
10931093
},
10941094
socketTimeoutMS: {
1095-
deprecated: 'Please use timeoutMS instead',
1095+
// TODO(NODE-6491): deprecated: 'Please use timeoutMS instead',
10961096
default: 0,
10971097
type: 'uint'
10981098
},
@@ -1163,7 +1163,7 @@ export const OPTIONS = {
11631163
}
11641164
},
11651165
waitQueueTimeoutMS: {
1166-
deprecated: 'Please use timeoutMS instead',
1166+
// TODO(NODE-6491): deprecated: 'Please use timeoutMS instead',
11671167
default: 0,
11681168
type: 'uint'
11691169
},

src/cursor/abstract_cursor.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ export interface AbstractCursorOptions extends BSONSerializeOptions {
113113
/**
114114
* When applicable `maxTimeMS` controls the amount of time the initial command
115115
* that constructs a cursor should take. (ex. find, aggregate, listCollections)
116-
* @deprecated Will be removed in the next major version. Please use timeoutMS instead.
117116
*/
118117
maxTimeMS?: number;
119118
/**
@@ -775,7 +774,6 @@ export abstract class AbstractCursor<
775774
* Set a maxTimeMS on the cursor query, allowing for hard timeout limits on queries (Only supported on MongoDB 2.6 or higher)
776775
*
777776
* @param value - Number of milliseconds to wait before aborting the query.
778-
* @deprecated Will be removed in the next major version. Please use the timeoutMS option instead.
779777
*/
780778
maxTimeMS(value: number): this {
781779
this.throwIfInitialized();

src/cursor/run_command_cursor.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ export class RunCommandCursor extends AbstractCursor {
8181
/**
8282
* Controls the `getMore.maxTimeMS` field. Only valid when cursor is tailable await
8383
* @param maxTimeMS - the number of milliseconds to wait for new data
84-
* @deprecated Will be removed in the next major version. Please use timeoutMS instead.
8584
*/
8685
public setMaxTimeMS(maxTimeMS: number): this {
8786
this.getMoreOptions.maxAwaitTimeMS = maxTimeMS;
@@ -118,7 +117,6 @@ export class RunCommandCursor extends AbstractCursor {
118117

119118
/**
120119
* Unsupported for RunCommandCursor: maxTimeMS must be configured directly on command document
121-
* @deprecated Will be removed in the next major version.
122120
*/
123121
public override maxTimeMS(_: number): never {
124122
throw new MongoAPIError(

src/error.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@ function isAggregateError(e: unknown): e is Error & { errors: Error[] } {
128128
* mongodb-client-encryption has a dependency on this error, it uses the constructor with a string argument
129129
*/
130130
export class MongoError extends Error {
131-
get [Symbol.toStringTag]() {
132-
return this.name;
133-
}
134131
/** @internal */
135132
[kErrorLabels]: Set<string>;
136133
/**

src/mongo_client.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,7 @@ export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeC
155155
tlsInsecure?: boolean;
156156
/** The time in milliseconds to attempt a connection before timing out. */
157157
connectTimeoutMS?: number;
158-
/**
159-
* The time in milliseconds to attempt a send or receive on a socket before the attempt times out.
160-
* @deprecated Will be removed in the next major version. Please use timeoutMS instead
161-
*/
158+
/** The time in milliseconds to attempt a send or receive on a socket before the attempt times out. */
162159
socketTimeoutMS?: number;
163160
/** An array or comma-delimited string of compressors to enable network compression for communication between this client and a mongod/mongos instance. */
164161
compressors?: CompressorName[] | string;
@@ -182,10 +179,7 @@ export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeC
182179
maxConnecting?: number;
183180
/** The maximum number of milliseconds that a connection can remain idle in the pool before being removed and closed. */
184181
maxIdleTimeMS?: number;
185-
/**
186-
* The maximum time in milliseconds that a thread can wait for a connection to become available.
187-
* @deprecated Will be removed in the next major version. Please use timeoutMS instead
188-
*/
182+
/** The maximum time in milliseconds that a thread can wait for a connection to become available. */
189183
waitQueueTimeoutMS?: number;
190184
/** Specify a read concern for the collection (only MongoDB 3.2 or higher supported) */
191185
readConcern?: ReadConcernLike;

src/operations/aggregate.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export interface AggregateOptions extends Omit<CommandOperationOptions, 'explain
2828
cursor?: Document;
2929
/**
3030
* Specifies a cumulative time limit in milliseconds for processing operations on the cursor. MongoDB interrupts the operation at the earliest following interrupt point.
31-
* @deprecated Will be removed in the next major version. Please use timeoutMS instead.
3231
*/
3332
maxTimeMS?: number;
3433
/** The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. */

src/operations/command.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export interface CommandOperationOptions
4242
collation?: CollationOptions;
4343
/**
4444
* maxTimeMS is a server-side time limit in milliseconds for processing an operation.
45-
* @deprecated Will be removed in the next major version. Please use timeoutMS instead.
4645
*/
4746
maxTimeMS?: number;
4847
/**

src/operations/count.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export interface CountOptions extends CommandOperationOptions {
1515
limit?: number;
1616
/**
1717
* Number of milliseconds to wait before aborting the query.
18-
* @deprecated Will be removed in the next major version. Please use timeoutMS instead.
1918
*/
2019
maxTimeMS?: number;
2120
/** An index name hint for the query. */

src/operations/estimated_document_count.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ 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.
1615
*/
1716
maxTimeMS?: number;
1817
}

src/sdam/server.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ export class Server extends TypedEventEmitter<ServerEvents> {
346346
operationError.code === MONGODB_ERROR_CODES.Reauthenticate
347347
) {
348348
await this.pool.reauthenticate(conn);
349-
// TODO(NODE-5682): Implement CSOT support for socket read/write at the connection layer
350349
try {
351350
const res = await conn.command(ns, cmd, finalOptions, responseType);
352351
throwIfWriteConcernError(res);

src/sdam/topology.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export interface SelectServerOptions {
180180
previousServer?: ServerDescription;
181181
/**
182182
* @internal
183-
* TODO(NODE-5685): Make this required
183+
* TODO(NODE-6496): Make this required by making ChangeStream use LegacyTimeoutContext
184184
* */
185185
timeoutContext?: TimeoutContext;
186186
}

src/timeout.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ type Reject = Parameters<ConstructorParameters<typeof Promise<never>>[0]>[1];
3232
* if interacted with exclusively through its public API
3333
* */
3434
export class Timeout extends Promise<never> {
35-
get [Symbol.toStringTag](): 'MongoDBTimeout' {
36-
return 'MongoDBTimeout';
37-
}
38-
3935
private id?: NodeJS.Timeout;
4036

4137
public readonly start: number;
@@ -112,17 +108,6 @@ export class Timeout extends Promise<never> {
112108
return new Timeout(undefined, { duration, unref });
113109
}
114110

115-
static is(timeout: unknown): timeout is Timeout {
116-
return (
117-
typeof timeout === 'object' &&
118-
timeout != null &&
119-
Symbol.toStringTag in timeout &&
120-
timeout[Symbol.toStringTag] === 'MongoDBTimeout' &&
121-
'then' in timeout &&
122-
typeof timeout.then === 'function'
123-
);
124-
}
125-
126111
static override reject(rejection?: Error): Timeout {
127112
return new Timeout(undefined, { duration: 0, unref: true, rejection });
128113
}

src/transactions.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ export interface TransactionOptions extends Omit<CommandOperationOptions, 'timeo
6868
writeConcern?: WriteConcern;
6969
/** A default read preference for commands in this transaction */
7070
readPreference?: ReadPreferenceLike;
71-
/**
72-
* Specifies the maximum amount of time to allow a commit action on a transaction to run in milliseconds
73-
* @deprecated This option is deprecated in favor of `timeoutMS` or `defaultTimeoutMS`.
74-
*/
71+
/** Specifies the maximum amount of time to allow a commit action on a transaction to run in milliseconds */
7572
maxCommitTimeMS?: number;
7673
}
7774

src/write_concern.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ export interface WriteConcernOptions {
1515
export interface WriteConcernSettings {
1616
/** The write concern */
1717
w?: W;
18-
/** The write concern timeout
19-
* @deprecated Will be removed in the next major version. Please use timeoutMS */
18+
/**
19+
* The write concern timeout.
20+
*/
2021
wtimeoutMS?: number;
2122
/** The journal write concern */
2223
journal?: boolean;
@@ -29,8 +30,6 @@ export interface WriteConcernSettings {
2930
j?: boolean;
3031
/**
3132
* The write concern timeout.
32-
* @deprecated
33-
* Will be removed in the next major version. Please use the wtimeoutMS option.
3433
*/
3534
wtimeout?: number;
3635
/**
@@ -69,7 +68,6 @@ export class WriteConcern {
6968
readonly journal?: boolean;
7069
/**
7170
* Specify a time limit to prevent write operations from blocking indefinitely.
72-
* @deprecated Will be removed in the next major version. Please use timeoutMS
7371
*/
7472
readonly wtimeoutMS?: number;
7573
/**

test/benchmarks/driverBench/common.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ function loadSpecString(filePath) {
2424
}
2525

2626
function makeClient() {
27-
this.client = new MongoClient(process.env.MONGODB_URI || 'mongodb://127.0.0.1:27017', {
28-
timeoutMS: 0
29-
});
27+
this.client = new MongoClient(process.env.MONGODB_URI || 'mongodb://127.0.0.1:27017');
3028
}
3129

3230
function connectClient() {

test/integration/client-side-operations-timeout/client_side_operations_timeout.prose.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ describe('CSOT spec prose tests', function () {
403403
});
404404
});
405405

406+
/** TODO(DRIVERS-2884): Drivers should not interrupt creating connections with a client-side timeout */
406407
context.skip('4. Background Connection Pooling', () => {
407408
/**
408409
* The tests in this section MUST only be run if the server version is 4.4 or higher and the URI has authentication

test/integration/client-side-operations-timeout/client_side_operations_timeout.spec.test.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,11 @@ import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner';
77
const skippedSpecs = {};
88

99
const skippedTests = {
10-
'timeoutMS can be configured on a MongoClient - createChangeStream on client': 'TODO(NODE-6305)',
11-
'timeoutMS applies to whole operation, not individual attempts - createChangeStream on client':
12-
'TODO(NODE-6305)',
13-
'Tailable cursor iteration timeoutMS is refreshed for getMore - failure': 'TODO(NODE-6305)',
10+
'Tailable cursor iteration timeoutMS is refreshed for getMore - failure': 'TODO(DRIVERS-2965)',
1411
'Tailable cursor awaitData iteration timeoutMS is refreshed for getMore - failure':
15-
'TODO(NODE-6305)',
16-
'command is not sent if RTT is greater than timeoutMS': 'TODO(DRIVERS-2965)',
17-
'Non=tailable cursor iteration timeoutMS is refreshed for getMore if timeoutMode is iteration - failure':
1812
'TODO(DRIVERS-2965)',
19-
'Non-tailable cursor lifetime remaining timeoutMS applied to getMore if timeoutMode is unset':
13+
'command is not sent if RTT is greater than timeoutMS': 'TODO(DRIVERS-2965)',
14+
'Non-tailable cursor iteration timeoutMS is refreshed for getMore if timeoutMode is iteration - failure':
2015
'TODO(DRIVERS-2965)',
2116
'maxTimeMS value in the command is less than timeoutMS':
2217
'TODO(DRIVERS-2970): see modified test in unified-csot-node-specs',

test/spec/client-side-operations-timeout/runCursorCommand.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
},
201201
"collection": "collection",
202202
"maxTimeMS": {
203-
"$$exists": true
203+
"$$exists": false
204204
}
205205
}
206206
}
@@ -210,7 +210,7 @@
210210
]
211211
},
212212
{
213-
"description": "Non=tailable cursor iteration timeoutMS is refreshed for getMore if timeoutMode is iteration - failure",
213+
"description": "Non-tailable cursor iteration timeoutMS is refreshed for getMore if timeoutMode is iteration - failure",
214214
"runOnRequirements": [
215215
{
216216
"serverless": "forbid"

test/spec/client-side-operations-timeout/runCursorCommand.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ tests:
7070
runOnRequirements:
7171
- serverless: forbid
7272
operations:
73-
# Block find/getMore for 15ms.
73+
# Block find/getMore for 60ms.
7474
- name: failPoint
7575
object: testRunner
7676
arguments:
@@ -83,8 +83,9 @@ tests:
8383
blockConnection: true
8484
blockTimeMS: 60
8585
# Run a find with timeoutMS less than double our failPoint blockTimeMS and
86-
# batchSize less than the total document count will cause a find and a getMore to be sent.
87-
# Both will block for 60ms so together they will go over the timeout.
86+
# batchSize less than the total document count will cause a find and a
87+
# getMore to be sent. Both will block for 60ms so together they will go
88+
# over the timeout.
8889
- name: runCursorCommand
8990
object: *db
9091
arguments:
@@ -106,12 +107,12 @@ tests:
106107
command:
107108
getMore: { $$type: [int, long] }
108109
collection: *collection
109-
maxTimeMS: { $$exists: true }
110+
maxTimeMS: { $$exists: false }
110111

111112
# If timeoutMode=ITERATION, timeoutMS applies separately to the initial find and the getMore on the cursor. Neither
112113
# command should have a maxTimeMS field. This is a failure test. The "find" inherits timeoutMS=100 and "getMore"
113114
# commands are blocked for 60ms, causing iteration to fail with a timeout error.
114-
- description: Non=tailable cursor iteration timeoutMS is refreshed for getMore if timeoutMode is iteration - failure
115+
- description: Non-tailable cursor iteration timeoutMS is refreshed for getMore if timeoutMode is iteration - failure
115116
runOnRequirements:
116117
- serverless: forbid
117118
operations:

test/types/mongodb.test-d.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,38 @@ declare const options: MongoDBDriver.MongoClientOptions;
2020
expectDeprecated(options.w);
2121
expectDeprecated(options.journal);
2222
expectDeprecated(options.wtimeoutMS);
23-
expectDeprecated(options.socketTimeoutMS);
24-
expectDeprecated(options.waitQueueTimeoutMS);
23+
// TODO(NODE-6491): expectDeprecated(options.socketTimeoutMS);
24+
// TODO(NODE-6491): expectDeprecated(options.waitQueueTimeoutMS);
2525
expectNotDeprecated(options.writeConcern);
2626
expectNotDeprecated(options.serverSelectionTimeoutMS);
2727
expectNotDeprecated(options.connectTimeoutMS);
2828

2929
expectType<WriteConcernSettings | WriteConcern | undefined>(options.writeConcern);
3030

3131
declare const estimatedDocumentCountOptions: MongoDBDriver.EstimatedDocumentCountOptions;
32-
expectDeprecated(estimatedDocumentCountOptions.maxTimeMS);
32+
// TODO(NODE-6491): expectDeprecated(estimatedDocumentCountOptions.maxTimeMS);
3333

3434
declare const countOptions: MongoDBDriver.CountOptions;
35-
expectDeprecated(countOptions.maxTimeMS);
35+
// TODO(NODE-6491): expectDeprecated(countOptions.maxTimeMS);
3636

3737
declare const commandOptions: MongoDBDriver.CommandOperationOptions;
38-
expectDeprecated(commandOptions.maxTimeMS);
38+
// TODO(NODE-6491): expectDeprecated(commandOptions.maxTimeMS);
3939

4040
declare const aggregateOptions: MongoDBDriver.AggregateOptions;
41-
expectDeprecated(aggregateOptions.maxTimeMS);
41+
// TODO(NODE-6491): expectDeprecated(aggregateOptions.maxTimeMS);
4242

4343
declare const runCommandCursor: MongoDBDriver.RunCommandCursor;
44-
expectDeprecated(runCommandCursor.setMaxTimeMS);
45-
expectDeprecated(runCommandCursor.maxTimeMS);
44+
// TODO(NODE-6491): expectDeprecated(runCommandCursor.setMaxTimeMS);
45+
// TODO(NODE-6491): expectDeprecated(runCommandCursor.maxTimeMS);
4646

4747
declare const cursorOptions: MongoDBDriver.AbstractCursorOptions;
48-
expectDeprecated(cursorOptions.maxTimeMS);
48+
// TODO(NODE-6491): expectDeprecated(cursorOptions.maxTimeMS);
4949

5050
declare const abstractCursor: MongoDBDriver.AbstractCursor;
51-
expectDeprecated(abstractCursor.maxTimeMS);
51+
// TODO(NODE-6491): expectDeprecated(abstractCursor.maxTimeMS);
5252

5353
declare const txnOptions: MongoDBDriver.TransactionOptions;
54-
expectDeprecated(txnOptions.maxCommitTimeMS);
54+
// TODO(NODE-6491): expectDeprecated(txnOptions.maxCommitTimeMS);
5555

5656
interface TSchema extends Document {
5757
name: string;

test/types/write_concern.test-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ expectNotAssignable<ListIndexesOptions>({ writeConcern: { w: 0 } });
1414
expectNotAssignable<ChangeStreamOptions>({ writeConcern: { w: 0 } });
1515

1616
declare const wc: WriteConcern;
17-
expectDeprecated(wc.wtimeoutMS);
17+
// TODO(NODE-6491): expectDeprecated(wc.wtimeoutMS);
1818
expectDeprecated(wc.wtimeout);

0 commit comments

Comments
 (0)