From 09d732ab4115be8df23f3f53c6ee1cd575c4bd29 Mon Sep 17 00:00:00 2001 From: Harvmaster Date: Mon, 13 Jul 2026 01:40:57 +0000 Subject: [PATCH] simplify while loop condition --- source/exponential-backoff.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) {