Skip to content

Commit cf8278c

Browse files
committed
fix: switch from Math.max to Math.min on retry backoff calculation
1 parent 127efbb commit cf8278c

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

.changeset/olive-ghosts-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@badrap/libapp": patch
3+
---
4+
5+
Switch from Math.max to Math.min on retry backoff calculation

src/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export class API<
219219
if (attempt >= maxRetries) {
220220
throw new UpdateFailed(err);
221221
}
222-
const backoff = Math.max(backoffStep * 2 ** attempt, maxBackoff);
222+
const backoff = Math.min(backoffStep * 2 ** attempt, maxBackoff);
223223
await sleep(backoff * (1 + Math.random() * jitterFactor));
224224
continue;
225225
}

0 commit comments

Comments
 (0)