diff --git a/src/sessions.ts b/src/sessions.ts index b766d40e28..20699d24ac 100644 --- a/src/sessions.ts +++ b/src/sessions.ts @@ -369,6 +369,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 { @@ -443,6 +448,11 @@ export class ClientSession extends TypedEventEmitter { * * **IMPORTANT:** This method requires the function passed in to return a Promise. That promise must be made by `await`-ing all operations in such a way that rejections are propagated to the returned promise. * + * **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 * - If all operations successfully complete and the `commitTransaction` operation is successful, then the provided function will return the result of the provided function. * - If the transaction is unable to complete or an error is thrown from within the provided function, then the provided function will throw an error.