Skip to content

Commit 7a12914

Browse files
W-A-Jamesbaileympearson
authored andcommitted
chore: allow clientBulkWrite to use TimeoutContext (#4251)
1 parent bfeeda9 commit 7a12914

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';
@@ -35,14 +36,15 @@ export class ClientBulkWriteOperation extends CommandOperation<ClientBulkWriteCu
3536
*/
3637
override async execute(
3738
server: Server,
38-
session: ClientSession | undefined
39+
session: ClientSession | undefined,
40+
timeoutContext: TimeoutContext
3941
): Promise<ClientBulkWriteCursorResponse> {
4042
let command;
4143

4244
if (server.description.type === ServerType.LoadBalancer) {
4345
if (session) {
4446
// Checkout a connection to build the command.
45-
const connection = await server.pool.checkOut();
47+
const connection = await server.pool.checkOut({ timeoutContext });
4648
// Pin the connection to the session so it get used to execute the command and we do not
4749
// perform a double check-in/check-out.
4850
session.pin(connection);
@@ -69,7 +71,13 @@ export class ClientBulkWriteOperation extends CommandOperation<ClientBulkWriteCu
6971
server.description.maxWriteBatchSize
7072
);
7173
}
72-
return await super.executeCommand(server, session, command, ClientBulkWriteCursorResponse);
74+
return await super.executeCommand(
75+
server,
76+
session,
77+
command,
78+
timeoutContext,
79+
ClientBulkWriteCursorResponse
80+
);
7381
}
7482
}
7583

0 commit comments

Comments
 (0)