From 6686768a5495130a1012d91c4a95bf47289837f2 Mon Sep 17 00:00:00 2001 From: Warren James Date: Tue, 15 Oct 2024 13:44:53 -0400 Subject: [PATCH] feat(NODE-3914): deprecate legacy timeout options --- src/connection_string.ts | 1 + src/utils.ts | 8 ++++++++ .../client_side_operations_timeout.spec.test.ts | 1 - 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/connection_string.ts b/src/connection_string.ts index 2bf1f6dd193..82ff04ce243 100644 --- a/src/connection_string.ts +++ b/src/connection_string.ts @@ -1209,6 +1209,7 @@ export const OPTIONS = { } } as OptionDescriptor, wtimeoutMS: { + deprecated: 'Please use timeoutMS instead', target: 'writeConcern', transform({ values: [value], options }) { const wc = WriteConcern.fromOptions({ diff --git a/src/utils.ts b/src/utils.ts index 15b3bab90f3..6146fe3995f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -569,6 +569,14 @@ 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; + } + } return result; } 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 c519da8039f..6708d7da89f 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,7 +7,6 @@ import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; const skippedSpecs = { 'change-streams': 'TODO(NODE-6035)', 'convenient-transactions': 'TODO(NODE-5687)', - 'deprecated-options': 'TODO(NODE-5689)', 'tailable-awaitData': 'TODO(NODE-6035)', 'tailable-non-awaitData': 'TODO(NODE-6035)' };