@@ -24,8 +24,8 @@ import { type MongoClient, type MongoClientOptions } from '../mongo_client';
24
24
import { type Filter , type WithId } from '../mongo_types' ;
25
25
import { type CreateCollectionOptions } from '../operations/create_collection' ;
26
26
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' ;
29
29
import * as cryptoCallbacks from './crypto_callbacks' ;
30
30
import {
31
31
MongoCryptCreateDataKeyError ,
@@ -123,7 +123,8 @@ export class ClientEncryption {
123
123
this . _proxyOptions = options . proxyOptions ?? { } ;
124
124
this . _tlsOptions = options . tlsOptions ?? { } ;
125
125
this . _kmsProviders = options . kmsProviders || { } ;
126
- this . _timeoutMS = options . timeoutMS ?? client . options . timeoutMS ;
126
+ const { timeoutMS } = resolveTimeoutOptions ( client , options ) ;
127
+ this . _timeoutMS = timeoutMS ;
127
128
128
129
if ( options . keyVaultNamespace == null ) {
129
130
throw new MongoCryptInvalidArgumentError ( 'Missing required option `keyVaultNamespace`' ) ;
@@ -277,14 +278,9 @@ export class ClientEncryption {
277
278
socketOptions : autoSelectSocketOptions ( this . _client . options )
278
279
} ) ;
279
280
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
+ ) ;
288
284
289
285
const { v : dataKeys } = deserialize ( await stateMachine . execute ( this , context , timeoutContext ) ) ;
290
286
if ( dataKeys . length === 0 ) {
0 commit comments