@@ -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