Skip to content

Commit

Permalink
docs(NODE-6192): clarify that operations should not be parallelized i…
Browse files Browse the repository at this point in the history
…n transactions (#4123)
  • Loading branch information
W-A-James committed May 28, 2024
1 parent 5b0f847 commit cb125fc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ export class ClientSession extends TypedEventEmitter<ClientSessionEvents> {
/**
* 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 {
Expand Down Expand Up @@ -439,6 +444,10 @@ export class ClientSession extends TypedEventEmitter<ClientSessionEvents> {
* **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)
Expand Down

0 comments on commit cb125fc

Please sign in to comment.