2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

fix(headers): fixed support for setting multiple header values from an iterated source; (#6885)

This commit is contained in:
Dmitriy Mozgovoy
2025-04-23 19:24:08 +03:00
committed by GitHub
parent e61a8934d8
commit f7a3b5e0f7
4 changed files with 55 additions and 7 deletions
+18
View File
@@ -0,0 +1,18 @@
export const retryNetwork = async (fn, retries = 3, delay = 1000) => {
let attempt = 0, sleep;
do {
try {
return await fn()
} catch (err) {
if (err.code === 'ERR_NETWORK' && attempt++ < retries) {
sleep = attempt * attempt * delay;
console.warn(`[ERR_NETWORK]: Attempt ${attempt}/${retries}${err.config ? ' [' + err.config.url + ']' : ''} sleep [${sleep}ms]`);
await new Promise(resolve => setTimeout(resolve, sleep));
} else {
throw err;
}
}
} while (true);
}