Skip to content

Commit 6cf961f

Browse files
committed
initialize attemptsMade
1 parent b7cf299 commit 6cf961f

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/operations/operation.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export abstract class AbstractOperation<TResult = any> {
7070
maxAttempts?: number;
7171

7272
/** Tracks how many attempts were made in the last executeOperation call. */
73-
attemptsMade?: number;
73+
attemptsMade: number;
7474

7575
private _session: ClientSession | undefined;
7676

@@ -88,6 +88,8 @@ export abstract class AbstractOperation<TResult = any> {
8888

8989
this.options = options;
9090
this.bypassPinningCheck = !!options.bypassPinningCheck;
91+
92+
this.attemptsMade = 0;
9193
}
9294

9395
/** Must match the first key of the command object sent to the server.

src/sessions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ export class ClientSession
517517
} catch (firstCommitError) {
518518
this.commitAttempted = true;
519519

520-
const remainingAttempts = MAX_RETRIES + 1 - (operation.attemptsMade ?? 1);
520+
const remainingAttempts = MAX_RETRIES + 1 - operation.attemptsMade;
521521
if (remainingAttempts <= 0) {
522522
throw firstCommitError;
523523
}

0 commit comments

Comments
 (0)