Skip to content

Commit d3031a5

Browse files
docs(NODE-6191): clarify that operations should not be parallelized in transactions (#4122)
Co-authored-by: Aditi Khare <[email protected]>
1 parent d1695c4 commit d3031a5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/sessions.ts

+10
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,11 @@ export class ClientSession extends TypedEventEmitter<ClientSessionEvents> {
369369
/**
370370
* Starts a new transaction with the given options.
371371
*
372+
* @remarks
373+
* **IMPORTANT**: Running operations in parallel is not supported during a transaction. The use of `Promise.all`,
374+
* `Promise.allSettled`, `Promise.race`, etc to parallelize operations inside a transaction is
375+
* undefined behaviour.
376+
*
372377
* @param options - Options for the transaction
373378
*/
374379
startTransaction(options?: TransactionOptions): void {
@@ -443,6 +448,11 @@ export class ClientSession extends TypedEventEmitter<ClientSessionEvents> {
443448
*
444449
* **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.
445450
*
451+
* **IMPORTANT:** Running operations in parallel is not supported during a transaction. The use of `Promise.all`,
452+
* `Promise.allSettled`, `Promise.race`, etc to parallelize operations inside a transaction is
453+
* undefined behaviour.
454+
*
455+
*
446456
* @remarks
447457
* - If all operations successfully complete and the `commitTransaction` operation is successful, then the provided function will return the result of the provided function.
448458
* - 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.

0 commit comments

Comments
 (0)