Skip to content

Commit

Permalink
chore: allow clientBulkWrite to use TimeoutContext (#4251)
Browse files Browse the repository at this point in the history
  • Loading branch information
W-A-James authored and dariakp committed Nov 6, 2024
1 parent c39d443 commit 30c7df4
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/operations/client_bulk_write/client_bulk_write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { MongoClientBulkWriteExecutionError, ServerType } from '../../beta';
import { ClientBulkWriteCursorResponse } from '../../cmap/wire_protocol/responses';
import type { Server } from '../../sdam/server';
import type { ClientSession } from '../../sessions';
import { type TimeoutContext } from '../../timeout';
import { MongoDBNamespace } from '../../utils';
import { CommandOperation } from '../command';
import { Aspect, defineAspects } from '../operation';
Expand Down Expand Up @@ -43,7 +44,8 @@ export class ClientBulkWriteOperation extends CommandOperation<ClientBulkWriteCu
*/
override async execute(
server: Server,
session: ClientSession | undefined
session: ClientSession | undefined,
timeoutContext: TimeoutContext
): Promise<ClientBulkWriteCursorResponse> {
let command;

Expand All @@ -52,7 +54,7 @@ export class ClientBulkWriteOperation extends CommandOperation<ClientBulkWriteCu
let connection;
if (!session.pinnedConnection) {
// Checkout a connection to build the command.
connection = await server.pool.checkOut();
connection = await server.pool.checkOut({ timeoutContext });
// Pin the connection to the session so it get used to execute the command and we do not
// perform a double check-in/check-out.
session.pin(connection);
Expand Down Expand Up @@ -93,7 +95,13 @@ export class ClientBulkWriteOperation extends CommandOperation<ClientBulkWriteCu
if (!this.canRetryWrite) {
this.options.willRetryWrite = false;
}
return await super.executeCommand(server, session, command, ClientBulkWriteCursorResponse);
return await super.executeCommand(
server,
session,
command,
timeoutContext,
ClientBulkWriteCursorResponse
);
}
}

Expand Down

0 comments on commit 30c7df4

Please sign in to comment.