From a333bd909089d7defd8acacb8d7bcf62084d07c7 Mon Sep 17 00:00:00 2001 From: Warren James Date: Tue, 28 May 2024 14:20:12 -0400 Subject: [PATCH] docs(NODE-6192): clarify that operations should not be parallelized in transactions --- src/sessions.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/sessions.ts b/src/sessions.ts index 544ab539368..ed53b38da8a 100644 --- a/src/sessions.ts +++ b/src/sessions.ts @@ -362,6 +362,11 @@ export class ClientSession extends TypedEventEmitter { /** * Starts a new transaction with the given options. * + * @remarks + * **IMPORTANT**: Running operations in parallel is not supported during a transaction. The use of `Promise.all`, + * `Promise.allSettled`, `Promise.race`, etc to parallelize operations inside a transaction is + * undefined behaviour. + * * @param options - Options for the transaction */ startTransaction(options?: TransactionOptions): void { @@ -439,6 +444,10 @@ export class ClientSession extends TypedEventEmitter { * **IMPORTANT:** This method requires the user to return a Promise, and `await` all operations. * Any callbacks that do not return a Promise will result in undefined behavior. * + * **IMPORTANT**: Running operations in parallel is not supported during a transaction. The use of `Promise.all`, + * `Promise.allSettled`, `Promise.race`, etc to parallelize operations inside a transaction is + * undefined behaviour. + * * @remarks * This function: * - Will return the command response from the final commitTransaction if every operation is successful (can be used as a truthy object)