@clerk/shared
Version:
Internal package utils used by the Clerk SDKs
21 lines (20 loc) • 486 B
JavaScript
// src/callWithRetry.ts
function wait(ms) {
return new Promise((res) => setTimeout(res, ms));
}
var MAX_NUMBER_OF_RETRIES = 5;
async function callWithRetry(fn, attempt = 1, maxAttempts = MAX_NUMBER_OF_RETRIES) {
try {
return await fn();
} catch (e) {
if (attempt >= maxAttempts) {
throw e;
}
await wait(2 ** attempt * 100);
return callWithRetry(fn, attempt + 1, maxAttempts);
}
}
export {
callWithRetry
};
//# sourceMappingURL=chunk-4PW5MDZA.mjs.map