mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-09 17:06:15 +00:00
Corrige la logique de jitter pour garantir une augmentation du délai dans le mécanisme de retry
This commit is contained in:
@@ -68,8 +68,8 @@ export class Retry {
|
||||
attempt += 1
|
||||
const retry = isRetryable ? isRetryable(e) : true
|
||||
if (!retry || attempt >= this.policy.maxAttempts) break
|
||||
// FIXED: Jitter should always increase delay, not decrease it (remove the -1)
|
||||
const jitter = 1 + Math.random() * this.policy.jitter
|
||||
// Apply jitter: vary delay by ±jitter% (e.g., jitter=0.2 means ±20%)
|
||||
const jitter = 1 + (Math.random() * 2 - 1) * this.policy.jitter
|
||||
const sleep = Math.min(this.policy.maxDelay, Math.max(0, Math.floor(delay * jitter)))
|
||||
await new Promise((r) => setTimeout(r, sleep))
|
||||
delay = Math.min(this.policy.maxDelay, Math.floor(delay * (this.policy.multiplier || 2)))
|
||||
|
||||
Reference in New Issue
Block a user