Skip to content

Commit a5e5e6d

Browse files
committed
refactor(NODE-6187): refactor to use TimeoutContext abstraction (#4131)
1 parent 450b163 commit a5e5e6d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/operations/execute_operation.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ type ResultTypeFromOperation<TOperation> =
5858
export async function executeOperation<
5959
T extends AbstractOperation<TResult>,
6060
TResult = ResultTypeFromOperation<T>
61+
<<<<<<< HEAD
6162
>(client: MongoClient, operation: T, timeoutContext?: TimeoutContext | null): Promise<TResult> {
63+
=======
64+
>(client: MongoClient, operation: T, timeoutContext?: TimeoutContext): Promise<TResult> {
65+
>>>>>>> e04694c3b (refactor(NODE-6187): refactor to use TimeoutContext abstraction (#4131))
6266
if (!(operation instanceof AbstractOperation)) {
6367
// TODO(NODE-3483): Extend MongoRuntimeError
6468
throw new MongoRuntimeError('This method requires a valid operation instance');
@@ -82,6 +86,12 @@ export async function executeOperation<
8286
throw new MongoInvalidArgumentError('ClientSession must be from the same MongoClient');
8387
}
8488

89+
timeoutContext ??= TimeoutContext.create({
90+
serverSelectionTimeoutMS: client.s.options.serverSelectionTimeoutMS,
91+
waitQueueTimeoutMS: client.s.options.waitQueueTimeoutMS,
92+
timeoutMS: operation.options.timeoutMS
93+
});
94+
8595
const readPreference = operation.readPreference ?? ReadPreference.primary;
8696
const inTransaction = !!session?.inTransaction();
8797

@@ -113,7 +123,8 @@ export async function executeOperation<
113123
topology,
114124
timeoutContext,
115125
session,
116-
readPreference
126+
readPreference,
127+
timeoutContext
117128
});
118129
} finally {
119130
if (session?.owner != null && session.owner === owner) {

0 commit comments

Comments
 (0)