diff --git a/etc/notes/errors.md b/etc/notes/errors.md index 114bc1b2e2c..0d3d85d50aa 100644 --- a/etc/notes/errors.md +++ b/etc/notes/errors.md @@ -111,7 +111,7 @@ This class should **never** be directly instantiated. ### `MongoOperationTimeoutError` -- TODO(NODE-5688): Add MongoOperationTimeoutError documentation +- TODO(NODE-6491): Add MongoOperationTimeoutError documentation ### MongoUnexpectedServerResponseError diff --git a/src/change_stream.ts b/src/change_stream.ts index ae57fb45f95..c7b21b7a202 100644 --- a/src/change_stream.ts +++ b/src/change_stream.ts @@ -543,6 +543,8 @@ export type ChangeStreamEvents< /** * @remarks Note that the `close` event is currently emitted whenever the internal `ChangeStreamCursor` * instance is closed, which can occur multiple times for a given `ChangeStream` instance. + * + * TODO(NODE-6434): address this issue in NODE-6434 */ close(): void; }; diff --git a/src/connection_string.ts b/src/connection_string.ts index 3aae2d0a654..ce20b9e90a9 100644 --- a/src/connection_string.ts +++ b/src/connection_string.ts @@ -1092,7 +1092,7 @@ export const OPTIONS = { type: 'string' }, socketTimeoutMS: { - deprecated: 'Please use timeoutMS instead', + // TODO(NODE-6491): deprecated: 'Please use timeoutMS instead', default: 0, type: 'uint' }, @@ -1163,7 +1163,7 @@ export const OPTIONS = { } }, waitQueueTimeoutMS: { - deprecated: 'Please use timeoutMS instead', + // TODO(NODE-6491): deprecated: 'Please use timeoutMS instead', default: 0, type: 'uint' }, diff --git a/src/cursor/abstract_cursor.ts b/src/cursor/abstract_cursor.ts index ab052dd11b2..66bfbed0078 100644 --- a/src/cursor/abstract_cursor.ts +++ b/src/cursor/abstract_cursor.ts @@ -113,7 +113,6 @@ 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; /** @@ -775,7 +774,6 @@ 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/run_command_cursor.ts b/src/cursor/run_command_cursor.ts index 3f6dd6d34e0..d5b90eeda9d 100644 --- a/src/cursor/run_command_cursor.ts +++ b/src/cursor/run_command_cursor.ts @@ -81,7 +81,6 @@ 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; @@ -118,7 +117,6 @@ export class RunCommandCursor extends AbstractCursor { /** * 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( diff --git a/src/error.ts b/src/error.ts index 9beda0f3664..c96b2e5b8dc 100644 --- a/src/error.ts +++ b/src/error.ts @@ -128,9 +128,6 @@ function isAggregateError(e: unknown): e is Error & { errors: Error[] } { * mongodb-client-encryption has a dependency on this error, it uses the constructor with a string argument */ export class MongoError extends Error { - get [Symbol.toStringTag]() { - return this.name; - } /** @internal */ [kErrorLabels]: Set; /** diff --git a/src/mongo_client.ts b/src/mongo_client.ts index f16d165a236..bab3d2c0f4d 100644 --- a/src/mongo_client.ts +++ b/src/mongo_client.ts @@ -155,10 +155,7 @@ 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. - * @deprecated Will be removed in the next major version. Please use timeoutMS instead - */ + /** The time in milliseconds to attempt a send or receive on a socket before the attempt times out. */ 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; @@ -182,10 +179,7 @@ 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. - * @deprecated Will be removed in the next major version. Please use timeoutMS instead - */ + /** The maximum time in milliseconds that a thread can wait for a connection to become available. */ 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 3407e64cebb..ab367a16a94 100644 --- a/src/operations/aggregate.ts +++ b/src/operations/aggregate.ts @@ -28,7 +28,6 @@ export interface AggregateOptions extends Omit { operationError.code === MONGODB_ERROR_CODES.Reauthenticate ) { await this.pool.reauthenticate(conn); - // TODO(NODE-5682): Implement CSOT support for socket read/write at the connection layer try { const res = await conn.command(ns, cmd, finalOptions, responseType); throwIfWriteConcernError(res); diff --git a/src/sdam/topology.ts b/src/sdam/topology.ts index 479003f0e35..e0d55dcff3a 100644 --- a/src/sdam/topology.ts +++ b/src/sdam/topology.ts @@ -180,7 +180,7 @@ export interface SelectServerOptions { previousServer?: ServerDescription; /** * @internal - * TODO(NODE-5685): Make this required + * TODO(NODE-6496): Make this required by making ChangeStream use LegacyTimeoutContext * */ timeoutContext?: TimeoutContext; } diff --git a/src/timeout.ts b/src/timeout.ts index 916e4594d27..47c27c7b90e 100644 --- a/src/timeout.ts +++ b/src/timeout.ts @@ -32,10 +32,6 @@ type Reject = Parameters>[0]>[1]; * if interacted with exclusively through its public API * */ export class Timeout extends Promise { - get [Symbol.toStringTag](): 'MongoDBTimeout' { - return 'MongoDBTimeout'; - } - private id?: NodeJS.Timeout; public readonly start: number; @@ -112,17 +108,6 @@ export class Timeout extends Promise { return new Timeout(undefined, { duration, unref }); } - static is(timeout: unknown): timeout is Timeout { - return ( - typeof timeout === 'object' && - timeout != null && - Symbol.toStringTag in timeout && - timeout[Symbol.toStringTag] === 'MongoDBTimeout' && - 'then' in timeout && - typeof timeout.then === 'function' - ); - } - static override reject(rejection?: Error): Timeout { return new Timeout(undefined, { duration: 0, unref: true, rejection }); } diff --git a/src/transactions.ts b/src/transactions.ts index db251c82c16..308d0ad90f6 100644 --- a/src/transactions.ts +++ b/src/transactions.ts @@ -68,10 +68,7 @@ export interface TransactionOptions extends Omit { /** * The tests in this section MUST only be run if the server version is 4.4 or higher and the URI has authentication diff --git a/test/integration/client-side-operations-timeout/client_side_operations_timeout.spec.test.ts b/test/integration/client-side-operations-timeout/client_side_operations_timeout.spec.test.ts index 2ea3a38bb79..2a8614b2dd8 100644 --- a/test/integration/client-side-operations-timeout/client_side_operations_timeout.spec.test.ts +++ b/test/integration/client-side-operations-timeout/client_side_operations_timeout.spec.test.ts @@ -7,16 +7,11 @@ import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; const skippedSpecs = {}; const skippedTests = { - 'timeoutMS can be configured on a MongoClient - createChangeStream on client': 'TODO(NODE-6305)', - 'timeoutMS applies to whole operation, not individual attempts - createChangeStream on client': - 'TODO(NODE-6305)', - 'Tailable cursor iteration timeoutMS is refreshed for getMore - failure': 'TODO(NODE-6305)', + 'Tailable cursor iteration timeoutMS is refreshed for getMore - failure': 'TODO(DRIVERS-2965)', 'Tailable cursor awaitData iteration timeoutMS is refreshed for getMore - failure': - 'TODO(NODE-6305)', - 'command is not sent if RTT is greater than timeoutMS': 'TODO(DRIVERS-2965)', - 'Non=tailable cursor iteration timeoutMS is refreshed for getMore if timeoutMode is iteration - failure': 'TODO(DRIVERS-2965)', - 'Non-tailable cursor lifetime remaining timeoutMS applied to getMore if timeoutMode is unset': + 'command is not sent if RTT is greater than timeoutMS': 'TODO(DRIVERS-2965)', + 'Non-tailable cursor iteration timeoutMS is refreshed for getMore if timeoutMode is iteration - failure': 'TODO(DRIVERS-2965)', 'maxTimeMS value in the command is less than timeoutMS': 'TODO(DRIVERS-2970): see modified test in unified-csot-node-specs', diff --git a/test/spec/client-side-operations-timeout/runCursorCommand.json b/test/spec/client-side-operations-timeout/runCursorCommand.json index 5fc0be33997..36f774fb5af 100644 --- a/test/spec/client-side-operations-timeout/runCursorCommand.json +++ b/test/spec/client-side-operations-timeout/runCursorCommand.json @@ -200,7 +200,7 @@ }, "collection": "collection", "maxTimeMS": { - "$$exists": true + "$$exists": false } } } @@ -210,7 +210,7 @@ ] }, { - "description": "Non=tailable cursor iteration timeoutMS is refreshed for getMore if timeoutMode is iteration - failure", + "description": "Non-tailable cursor iteration timeoutMS is refreshed for getMore if timeoutMode is iteration - failure", "runOnRequirements": [ { "serverless": "forbid" diff --git a/test/spec/client-side-operations-timeout/runCursorCommand.yml b/test/spec/client-side-operations-timeout/runCursorCommand.yml index 16a648e0280..91a18d6dd81 100644 --- a/test/spec/client-side-operations-timeout/runCursorCommand.yml +++ b/test/spec/client-side-operations-timeout/runCursorCommand.yml @@ -70,7 +70,7 @@ tests: runOnRequirements: - serverless: forbid operations: - # Block find/getMore for 15ms. + # Block find/getMore for 60ms. - name: failPoint object: testRunner arguments: @@ -83,8 +83,9 @@ tests: blockConnection: true blockTimeMS: 60 # Run a find with timeoutMS less than double our failPoint blockTimeMS and - # batchSize less than the total document count will cause a find and a getMore to be sent. - # Both will block for 60ms so together they will go over the timeout. + # batchSize less than the total document count will cause a find and a + # getMore to be sent. Both will block for 60ms so together they will go + # over the timeout. - name: runCursorCommand object: *db arguments: @@ -106,12 +107,12 @@ tests: command: getMore: { $$type: [int, long] } collection: *collection - maxTimeMS: { $$exists: true } + maxTimeMS: { $$exists: false } # If timeoutMode=ITERATION, timeoutMS applies separately to the initial find and the getMore on the cursor. Neither # command should have a maxTimeMS field. This is a failure test. The "find" inherits timeoutMS=100 and "getMore" # commands are blocked for 60ms, causing iteration to fail with a timeout error. - - description: Non=tailable cursor iteration timeoutMS is refreshed for getMore if timeoutMode is iteration - failure + - description: Non-tailable cursor iteration timeoutMS is refreshed for getMore if timeoutMode is iteration - failure runOnRequirements: - serverless: forbid operations: diff --git a/test/types/mongodb.test-d.ts b/test/types/mongodb.test-d.ts index c87933514f2..4037a18159d 100644 --- a/test/types/mongodb.test-d.ts +++ b/test/types/mongodb.test-d.ts @@ -20,8 +20,8 @@ declare const options: MongoDBDriver.MongoClientOptions; expectDeprecated(options.w); expectDeprecated(options.journal); expectDeprecated(options.wtimeoutMS); -expectDeprecated(options.socketTimeoutMS); -expectDeprecated(options.waitQueueTimeoutMS); +// TODO(NODE-6491): expectDeprecated(options.socketTimeoutMS); +// TODO(NODE-6491): expectDeprecated(options.waitQueueTimeoutMS); expectNotDeprecated(options.writeConcern); expectNotDeprecated(options.serverSelectionTimeoutMS); expectNotDeprecated(options.connectTimeoutMS); @@ -29,29 +29,29 @@ expectNotDeprecated(options.connectTimeoutMS); expectType(options.writeConcern); declare const estimatedDocumentCountOptions: MongoDBDriver.EstimatedDocumentCountOptions; -expectDeprecated(estimatedDocumentCountOptions.maxTimeMS); +// TODO(NODE-6491): expectDeprecated(estimatedDocumentCountOptions.maxTimeMS); declare const countOptions: MongoDBDriver.CountOptions; -expectDeprecated(countOptions.maxTimeMS); +// TODO(NODE-6491): expectDeprecated(countOptions.maxTimeMS); declare const commandOptions: MongoDBDriver.CommandOperationOptions; -expectDeprecated(commandOptions.maxTimeMS); +// TODO(NODE-6491): expectDeprecated(commandOptions.maxTimeMS); declare const aggregateOptions: MongoDBDriver.AggregateOptions; -expectDeprecated(aggregateOptions.maxTimeMS); +// TODO(NODE-6491): expectDeprecated(aggregateOptions.maxTimeMS); declare const runCommandCursor: MongoDBDriver.RunCommandCursor; -expectDeprecated(runCommandCursor.setMaxTimeMS); -expectDeprecated(runCommandCursor.maxTimeMS); +// TODO(NODE-6491): expectDeprecated(runCommandCursor.setMaxTimeMS); +// TODO(NODE-6491): expectDeprecated(runCommandCursor.maxTimeMS); declare const cursorOptions: MongoDBDriver.AbstractCursorOptions; -expectDeprecated(cursorOptions.maxTimeMS); +// TODO(NODE-6491): expectDeprecated(cursorOptions.maxTimeMS); declare const abstractCursor: MongoDBDriver.AbstractCursor; -expectDeprecated(abstractCursor.maxTimeMS); +// TODO(NODE-6491): expectDeprecated(abstractCursor.maxTimeMS); declare const txnOptions: MongoDBDriver.TransactionOptions; -expectDeprecated(txnOptions.maxCommitTimeMS); +// TODO(NODE-6491): expectDeprecated(txnOptions.maxCommitTimeMS); interface TSchema extends Document { name: string; diff --git a/test/types/write_concern.test-d.ts b/test/types/write_concern.test-d.ts index fefcaf4fc84..2b10824a1c6 100644 --- a/test/types/write_concern.test-d.ts +++ b/test/types/write_concern.test-d.ts @@ -14,5 +14,5 @@ expectNotAssignable({ writeConcern: { w: 0 } }); expectNotAssignable({ writeConcern: { w: 0 } }); declare const wc: WriteConcern; -expectDeprecated(wc.wtimeoutMS); +// TODO(NODE-6491): expectDeprecated(wc.wtimeoutMS); expectDeprecated(wc.wtimeout); diff --git a/test/unit/explain.test.ts b/test/unit/explain.test.ts index 282a6fe7c8e..adfcfd866c6 100644 --- a/test/unit/explain.test.ts +++ b/test/unit/explain.test.ts @@ -51,7 +51,7 @@ describe('class Explain {}', function () { }); }); - describe('parseTimeoutOptions()', function () { + describe('resolveExplainTimeoutOptions()', function () { const cursor = new FindCursor( new MongoClient('mongodb://localhost:27027'), MongoDBNamespace.fromString('foo.bar'), @@ -59,19 +59,19 @@ describe('class Explain {}', function () { {} ); - it('parseTimeoutOptions()', function () { + it('when called with no arguments returns neither timeout nor explain', function () { const { timeout, explain } = cursor.resolveExplainTimeoutOptions(); expect(timeout).to.be.undefined; expect(explain).to.be.undefined; }); - it('parseTimeoutOptions()', function () { + it('when called with a timeoutMS option returns only timeout options', function () { const { timeout, explain } = cursor.resolveExplainTimeoutOptions({ timeoutMS: 1_000 }); expect(timeout).to.deep.equal({ timeoutMS: 1_000 }); expect(explain).to.be.undefined; }); - it('parseTimeoutOptions()', function () { + it('when called with explain settings returns only explain options', function () { const { timeout, explain } = cursor.resolveExplainTimeoutOptions({ verbosity: 'queryPlanner' }); @@ -79,7 +79,7 @@ describe('class Explain {}', function () { expect(explain).to.deep.equal({ verbosity: 'queryPlanner' }); }); - it('parseTimeoutOptions()', function () { + it('when called with explain settings and timeout options returns both explain and timeout options', function () { const { timeout, explain } = cursor.resolveExplainTimeoutOptions( { verbosity: 'queryPlanner' }, { timeoutMS: 1_000 } diff --git a/test/unit/timeout.test.ts b/test/unit/timeout.test.ts index 119d0516a9c..1dd7e83feb5 100644 --- a/test/unit/timeout.test.ts +++ b/test/unit/timeout.test.ts @@ -14,9 +14,12 @@ describe('Timeout', function () { let timeout: Timeout; beforeEach(() => { - if (Timeout.is(timeout)) { - timeout.clear(); - } + timeout = null; + }); + + beforeEach(() => { + timeout?.clear(); + timeout = null; }); describe('expires()', function () { @@ -71,57 +74,6 @@ describe('Timeout', function () { }); }); }); - - describe('is()', function () { - context('when called on a Timeout instance', function () { - it('returns true', function () { - expect(Timeout.is(Timeout.expires(0))).to.be.true; - }); - }); - - context('when called on a nullish object ', function () { - it('returns false', function () { - expect(Timeout.is(undefined)).to.be.false; - expect(Timeout.is(null)).to.be.false; - }); - }); - - context('when called on a primitive type', function () { - it('returns false', function () { - expect(Timeout.is(1)).to.be.false; - expect(Timeout.is('hello')).to.be.false; - expect(Timeout.is(true)).to.be.false; - expect(Timeout.is(1n)).to.be.false; - expect(Timeout.is(Symbol.for('test'))).to.be.false; - }); - }); - - context('when called on a Promise-like object with a matching toStringTag', function () { - it('returns true', function () { - const timeoutLike = { - [Symbol.toStringTag]: 'MongoDBTimeout', - then() { - return 0; - } - }; - - expect(Timeout.is(timeoutLike)).to.be.true; - }); - }); - - context('when called on a Promise-like object without a matching toStringTag', function () { - it('returns false', function () { - const timeoutLike = { - [Symbol.toStringTag]: 'lol', - then() { - return 0; - } - }; - - expect(Timeout.is(timeoutLike)).to.be.false; - }); - }); - }); }); describe('TimeoutContext', function () {