Skip to content

Commit cb125fc

Browse files
authored
docs(NODE-6192): clarify that operations should not be parallelized in transactions (#4123)
1 parent 5b0f847 commit cb125fc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/sessions.ts

+9
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ export class ClientSession extends TypedEventEmitter<ClientSessionEvents> {
362362
/**
363363
* Starts a new transaction with the given options.
364364
*
365+
* @remarks
366+
* **IMPORTANT**: Running operations in parallel is not supported during a transaction. The use of `Promise.all`,
367+
* `Promise.allSettled`, `Promise.race`, etc to parallelize operations inside a transaction is
368+
* undefined behaviour.
369+
*
365370
* @param options - Options for the transaction
366371
*/
367372
startTransaction(options?: TransactionOptions): void {
@@ -439,6 +444,10 @@ export class ClientSession extends TypedEventEmitter<ClientSessionEvents> {
439444
* **IMPORTANT:** This method requires the user to return a Promise, and `await` all operations.
440445
* Any callbacks that do not return a Promise will result in undefined behavior.
441446
*
447+
* **IMPORTANT**: Running operations in parallel is not supported during a transaction. The use of `Promise.all`,
448+
* `Promise.allSettled`, `Promise.race`, etc to parallelize operations inside a transaction is
449+
* undefined behaviour.
450+
*
442451
* @remarks
443452
* This function:
444453
* - Will return the command response from the final commitTransaction if every operation is successful (can be used as a truthy object)

0 commit comments

Comments
 (0)