Skip to content

Commit 3991e40

Browse files
committed
chore: comments and remove stub from testing
1 parent b00507c commit 3991e40

File tree

2 files changed

+217
-163
lines changed

2 files changed

+217
-163
lines changed

src/client-side-encryption/client_encryption.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import { type MongoClient, type MongoClientOptions } from '../mongo_client';
2424
import { type Filter, type WithId } from '../mongo_types';
2525
import { type CreateCollectionOptions } from '../operations/create_collection';
2626
import { type DeleteResult } from '../operations/delete';
27-
import { CSOTTimeoutContext } from '../timeout';
28-
import { MongoDBCollectionNamespace } from '../utils';
27+
import { CSOTTimeoutContext, TimeoutContext } from '../timeout';
28+
import { MongoDBCollectionNamespace, resolveTimeoutOptions } from '../utils';
2929
import * as cryptoCallbacks from './crypto_callbacks';
3030
import {
3131
MongoCryptCreateDataKeyError,
@@ -123,7 +123,8 @@ export class ClientEncryption {
123123
this._proxyOptions = options.proxyOptions ?? {};
124124
this._tlsOptions = options.tlsOptions ?? {};
125125
this._kmsProviders = options.kmsProviders || {};
126-
this._timeoutMS = options.timeoutMS ?? client.options.timeoutMS;
126+
const { timeoutMS } = resolveTimeoutOptions(client, options);
127+
this._timeoutMS = timeoutMS;
127128

128129
if (options.keyVaultNamespace == null) {
129130
throw new MongoCryptInvalidArgumentError('Missing required option `keyVaultNamespace`');
@@ -277,14 +278,9 @@ export class ClientEncryption {
277278
socketOptions: autoSelectSocketOptions(this._client.options)
278279
});
279280

280-
const timeoutContext: CSOTTimeoutContext | undefined =
281-
typeof this._timeoutMS === 'number'
282-
? (CSOTTimeoutContext.create({
283-
serverSelectionTimeoutMS: this._client.s.options.serverSelectionTimeoutMS,
284-
waitQueueTimeoutMS: this._client.s.options.waitQueueTimeoutMS,
285-
timeoutMS: this._timeoutMS
286-
}) as CSOTTimeoutContext)
287-
: undefined;
281+
const timeoutContext = TimeoutContext.create(
282+
resolveTimeoutOptions(this._client, { timeoutMS: this._timeoutMS })
283+
);
288284

289285
const { v: dataKeys } = deserialize(await stateMachine.execute(this, context, timeoutContext));
290286
if (dataKeys.length === 0) {

0 commit comments

Comments
 (0)