Created
November 2, 2022 15:21
-
-
Save CodeMan99/b406a708bf23146b9313fab41f684a73 to your computer and use it in GitHub Desktop.
Exponential Back-Off
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// snippet based on https://github.com/tim-kos/node-retry#retrytimeoutsoptions | |
const timeouts = Array.from({length: 10}, (_, i) => { | |
const random = 1; | |
const minTimeout = 10; | |
const factor = 2; | |
const attempt = i; | |
const maxTimeout = 6000; | |
return Math.min(random * minTimeout * Math.pow(factor, attempt), maxTimeout); | |
}); | |
console.dir(timeouts); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment