Open yokomotod opened 3 years ago
Too bad this library isn't being maintained anymore. Ended up fixing this by wrapping the function to be retried with my own try/catch that calls what I had in onRetry
, eg.
async withRetry(fn) {
let attempt = 0;
const wrapper = async (...params) => {
try {
attempt++;
return await fn(...params);
} catch (e) {
console.warn(`Retrying attempt ${attempt}`, e);
// what I would have had in my onRetry
if (e.code == 401 || e.code == 400) {
await maybeThrowsError();
}
// always throw original error
throw e;
}
}
return await retry(wrapper, { retries: 1 });
}
Throwing an error in
onRetry
seems like a weird behavior to me.Result:
I expected that it caught once without retry like:
otherwise, with retry like:
Is this a bug?