Skip to content

Commit 6aa5086

Browse files
fix tests and rename SystemOverloadError -> SystemOverloadedError
1 parent 59ed38f commit 6aa5086

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export const MongoErrorLabel = Object.freeze({
100100
PoolRequestedRetry: 'PoolRequestedRetry',
101101
InterruptInUseConnections: 'InterruptInUseConnections',
102102
NoWritesPerformed: 'NoWritesPerformed',
103-
SystemOverloadError: 'SystemOverloadError',
103+
SystemOverloadedError: 'SystemOverloadedError',
104104
RetryableError: 'RetryableError'
105105
} as const);
106106

src/operations/execute_operation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ async function executeOperationWithRetries<
261261

262262
while (true) {
263263
if (previousOperationError) {
264-
if (previousOperationError.hasErrorLabel(MongoErrorLabel.SystemOverloadError)) {
264+
if (previousOperationError.hasErrorLabel(MongoErrorLabel.SystemOverloadedError)) {
265265
systemOverloadRetryAttempt += 1;
266266

267267
if (
@@ -279,7 +279,7 @@ async function executeOperationWithRetries<
279279
}
280280

281281
// if we have exhausted overload retry attempts, throw.
282-
if (systemOverloadRetryAttempt > maxSystemOverloadRetryAttempts) {
282+
if (systemOverloadRetryAttempt >= maxSystemOverloadRetryAttempts) {
283283
throw previousOperationError;
284284
}
285285

@@ -311,7 +311,7 @@ async function executeOperationWithRetries<
311311
} else {
312312
nonOverloadRetryAttempt++;
313313
// we have no more retry attempts, throw.
314-
if (nonOverloadRetryAttempt > maxNonOverloadRetryAttempts) {
314+
if (nonOverloadRetryAttempt >= maxNonOverloadRetryAttempts) {
315315
throw previousOperationError;
316316
}
317317

@@ -381,7 +381,7 @@ async function executeOperationWithRetries<
381381
} catch (operationError) {
382382
if (!(operationError instanceof MongoError)) throw operationError;
383383

384-
if (!operationError.hasErrorLabel(MongoErrorLabel.SystemOverloadError)) {
384+
if (!operationError.hasErrorLabel(MongoErrorLabel.SystemOverloadedError)) {
385385
// if an operation fails with an error that does not contain the SystemOverloadError, deposit 1 token.
386386
topology.tokenBucket.deposit(RETRY_COST);
387387
}

0 commit comments

Comments
 (0)