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 baileympearson committed Oct 1, 2024
1 parent bfeeda9 commit 7a12914
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 @@ -35,14 +36,15 @@ export class ClientBulkWriteOperation extends CommandOperation<ClientBulkWriteCu
*/
override async execute(
server: Server,
session: ClientSession | undefined
session: ClientSession | undefined,
timeoutContext: TimeoutContext
): Promise<ClientBulkWriteCursorResponse> {
let command;

if (server.description.type === ServerType.LoadBalancer) {
if (session) {
// Checkout a connection to build the command.
const connection = await server.pool.checkOut();
const 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 All @@ -69,7 +71,13 @@ export class ClientBulkWriteOperation extends CommandOperation<ClientBulkWriteCu
server.description.maxWriteBatchSize
);
}
return await super.executeCommand(server, session, command, ClientBulkWriteCursorResponse);
return await super.executeCommand(
server,
session,
command,
timeoutContext,
ClientBulkWriteCursorResponse
);
}
}

Expand Down

0 comments on commit 7a12914

Please sign in to comment.