Skip to content

Commit d3dd724

Browse files
committed
docs(NODE-6191): clarify that operations should not be parallelized in transactions
1 parent d1695c4 commit d3dd724

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/sessions.ts

Lines changed: 9 additions & 0 deletions
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 {
@@ -449,6 +454,10 @@ export class ClientSession extends TypedEventEmitter<ClientSessionEvents> {
449454
* - If the transaction is manually aborted within the provided function it will not throw.
450455
* - If the driver needs to attempt to retry the operations, the provided function may be called multiple times.
451456
*
457+
* **IMPORTANT:** Running operations in parallel is not supported during a transaction. The use of `Promise.all`,
458+
* `Promise.allSettled`, `Promise.race`, etc to parallelize operations inside a transaction is
459+
* undefined behaviour.
460+
*
452461
* Checkout a descriptive example here:
453462
* @see https://www.mongodb.com/blog/post/quick-start-nodejs--mongodb--how-to-implement-transactions
454463
*

0 commit comments

Comments
 (0)