Skip to content

Commit 6576b99

Browse files
committed
chore: add timeout context to rewrapManyDataKey
1 parent 9777eff commit 6576b99

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/client-side-encryption/client_encryption.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ 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';
2728
import { MongoDBCollectionNamespace } from '../utils';
2829
import * as cryptoCallbacks from './crypto_callbacks';
2930
import {
@@ -276,7 +277,16 @@ export class ClientEncryption {
276277
socketOptions: autoSelectSocketOptions(this._client.options)
277278
});
278279

279-
const { v: dataKeys } = deserialize(await stateMachine.execute(this, context));
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;
288+
289+
const { v: dataKeys } = deserialize(await stateMachine.execute(this, context, timeoutContext));
280290
if (dataKeys.length === 0) {
281291
return {};
282292
}
@@ -307,7 +317,7 @@ export class ClientEncryption {
307317
.collection<DataKey>(collectionName)
308318
.bulkWrite(replacements, {
309319
writeConcern: { w: 'majority' },
310-
timeoutMS: this._timeoutMS
320+
timeoutMS: timeoutContext?.remainingTimeMS
311321
});
312322

313323
return { bulkWriteResult: result };

test/integration/client-side-encryption/driver.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ describe('Client Side Encryption Functional', function () {
415415
}
416416
);
417417

418-
describe.only('CSOT on ClientEncryption', function () {
418+
describe('CSOT on ClientEncryption', function () {
419419
function makeBlockingFailFor(command: string, blockTimeMS: number) {
420420
beforeEach(async function () {
421421
const utilClient = this.configuration.newClient();

0 commit comments

Comments
 (0)