Skip to content

Commit dd4661e

Browse files
committed
feat: adds jitter to networkRetryDelay
1 parent 9b4bce0 commit dd4661e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/core/concurrency-queue.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,19 @@ export function ConcurrencyQueue ({ axios, config }) {
7272
return null
7373
}
7474

75-
// Calculate retry delay with backoff strategy
75+
// Calculate retry delay with jitter and backoff strategy
7676
const calculateNetworkRetryDelay = (attempt) => {
7777
const baseDelay = this.config.networkRetryDelay
78+
let delay
79+
7880
if (this.config.networkBackoffStrategy === 'exponential') {
79-
return baseDelay * Math.pow(2, attempt - 1)
81+
delay = baseDelay * Math.pow(2, attempt - 1)
82+
} else {
83+
delay = baseDelay // Fixed delay
8084
}
81-
return baseDelay // Fixed delay
85+
86+
const jitter = (Math.random() * 100)
87+
return delay + jitter
8288
}
8389

8490
// Log retry attempts

0 commit comments

Comments
 (0)