Skip to content

Commit 580130d

Browse files
W-A-Jamesnbbeeken
authored andcommitted
chore: allow clientBulkWrite to use TimeoutContext (#4251)
1 parent 1eb0b74 commit 580130d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/operations/client_bulk_write/client_bulk_write.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { MongoClientBulkWriteExecutionError, ServerType } from '../../beta';
22
import { ClientBulkWriteCursorResponse } from '../../cmap/wire_protocol/responses';
33
import type { Server } from '../../sdam/server';
44
import type { ClientSession } from '../../sessions';
5+
import { type TimeoutContext } from '../../timeout';
56
import { MongoDBNamespace } from '../../utils';
67
import { CommandOperation } from '../command';
78
import { Aspect, defineAspects } from '../operation';
@@ -43,7 +44,8 @@ export class ClientBulkWriteOperation extends CommandOperation<ClientBulkWriteCu
4344
*/
4445
override async execute(
4546
server: Server,
46-
session: ClientSession | undefined
47+
session: ClientSession | undefined,
48+
timeoutContext: TimeoutContext
4749
): Promise<ClientBulkWriteCursorResponse> {
4850
let command;
4951

@@ -52,7 +54,7 @@ export class ClientBulkWriteOperation extends CommandOperation<ClientBulkWriteCu
5254
let connection;
5355
if (!session.pinnedConnection) {
5456
// Checkout a connection to build the command.
55-
connection = await server.pool.checkOut();
57+
connection = await server.pool.checkOut({ timeoutContext });
5658
// Pin the connection to the session so it get used to execute the command and we do not
5759
// perform a double check-in/check-out.
5860
session.pin(connection);
@@ -93,7 +95,13 @@ export class ClientBulkWriteOperation extends CommandOperation<ClientBulkWriteCu
9395
if (!this.canRetryWrite) {
9496
this.options.willRetryWrite = false;
9597
}
96-
return await super.executeCommand(server, session, command, ClientBulkWriteCursorResponse);
98+
return await super.executeCommand(
99+
server,
100+
session,
101+
command,
102+
timeoutContext,
103+
ClientBulkWriteCursorResponse
104+
);
97105
}
98106
}
99107

0 commit comments

Comments
 (0)