Skip to content

Commit

Permalink
fix: "willRetryWrites"
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Mar 14, 2022
1 parent ffba0f4 commit ff5b12e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/operations/execute_operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ function executeWithServerSelection<TResult>(

if ((hasReadAspect && willRetryRead) || (hasWriteAspect && willRetryWrite)) {
if (hasWriteAspect && willRetryWrite) {
operation.options.willRetryWrite = true;
operation.options.willRetryWrites = true;
session.incrementTransactionNumber();
}

Expand Down
2 changes: 1 addition & 1 deletion src/operations/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export abstract class AbstractOperation<TResult = any> {
bsonOptions?: BSONSerializeOptions;

// TODO: Each operation defines its own options, there should be better typing here
options: Document;
options: OperationOptions;

[kSession]: ClientSession | undefined;

Expand Down
6 changes: 3 additions & 3 deletions src/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -964,10 +964,10 @@ export function applySession(
command.lsid = serverSession.id;

// first apply non-transaction-specific sessions data
const inTransaction = session.inTransaction() || isTransactionCommand(command);
const isRetryableWrite = options?.willRetryWrite || false;
const inTransaction = session.inTransaction() ?? isTransactionCommand(command);
const isRetryableWrite = options.willRetryWrites ?? false;

if (serverSession.txnNumber && (isRetryableWrite || inTransaction)) {
if (isRetryableWrite || inTransaction) {
command.txnNumber = Long.fromNumber(serverSession.txnNumber);
}

Expand Down

0 comments on commit ff5b12e

Please sign in to comment.