diff --git a/src/connection_string.ts b/src/connection_string.ts index 2bf1f6dd19..82ff04ce24 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 04174813c9..92596a5d6b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -556,6 +556,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; }