add exponential backoff

This commit is contained in:
João Moreno 2020-12-07 15:02:48 +01:00
parent 66aab34216
commit 36628d73b9

View file

@ -74,6 +74,9 @@ async function retry<T>(fn: () => Promise<T>): Promise<T> {
if (!/ECONNRESET/.test(err.message)) {
throw err;
}
// maximum delay is 10th retry: ~3 seconds
await new Promise(c => setTimeout(c, (Math.random() * 200) + (50 * Math.pow(1.5, run))));
}
}