@@ -24,8 +24,8 @@ import { type MongoClient, type MongoClientOptions } from '../mongo_client';
2424import { type Filter , type WithId } from '../mongo_types' ;
2525import { type CreateCollectionOptions } from '../operations/create_collection' ;
2626import { 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' ;
2929import * as cryptoCallbacks from './crypto_callbacks' ;
3030import {
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