Skip to content

Commit 272c275

Browse files
b84330808claude
andcommitted
fix(sio-client): skip the jitter when the delay is not finite
Suggested in review: this also covers ms + deviation overflowing near Number.MAX_VALUE, and keeps returning the max delay after many attempts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f77c8b6 commit 272c275

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

  • packages/socket.io-client/lib/contrib

‎packages/socket.io-client/lib/contrib/backo2.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ Backoff.prototype.duration = function(){
3030
var ms = this.ms * Math.pow(this.factor, this.attempts++);
3131
// after many attempts, the value overflows to Infinity, and the jitter
3232
// below would then compute Infinity - Infinity = NaN (so a delay of 0)
33-
ms = Math.min(ms, Number.MAX_VALUE);
34-
if (this.jitter) {
33+
if (this.jitter && isFinite(ms)) {
3534
var rand = Math.random();
3635
var deviation = Math.floor(rand * this.jitter * ms);
3736
ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;

0 commit comments

Comments
 (0)