diff --git a/source/exponential-backoff.ts b/source/exponential-backoff.ts index 06b6b07..3ae558f 100644 --- a/source/exponential-backoff.ts +++ b/source/exponential-backoff.ts @@ -72,7 +72,10 @@ export class ExponentialBackoff { let attempt = 0; - while (attempt < this.options.maxAttempts || this.options.maxAttempts == 0) { + // If the max attempts is 0, we should continue indefinitely. + const unlimitedAttempts = this.options.maxAttempts === 0; + + while (attempt < this.options.maxAttempts || unlimitedAttempts) { try { return await taskFn(); } catch (error) {