You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know there's feature to bail out conditionally, but I think it would be useful to have a function that is called as soon as the operation fails, and the return value of that function should decide whether or not the next retry should happen.
So if (!op.retry(err)) { would just become something like if (!options.shouldRetry(err) || !op.retry(err)) {.
Current alternative to this would be to have a try/catch in the retrier function, decide in catch, throw if need to retry, and swallow and bail if needed. But this is a lot of boilerplate and can not be extracted into a separate function.
While having a function in option would be much easier.
Did it make sense?
The text was updated successfully, but these errors were encountered:
That's not so much boilerplate you can bail return in a catch if it matches your condition otherwise rethrow. Here's an example from an intercom api call:
awaitretry(asyncbail=>{try{constres=awaitclient.users.create(intercomUser)if([400,401,409,500].indexOf(res.statusCode)!==-1){// don't retrybail(newError(`Could not retry: status code ${res.statusCode}`))}}catch(error){// fail silently don't bailif(/Multipleexisting/.test(error.message)){return}throw(error)}})
EDIT: do not bail in the catch, somehow it throws unhandeld
I know there's feature to bail out conditionally, but I think it would be useful to have a function that is called as soon as the operation fails, and the return value of that function should decide whether or not the next retry should happen.
So
if (!op.retry(err)) {
would just become something likeif (!options.shouldRetry(err) || !op.retry(err)) {
.Current alternative to this would be to have a try/catch in the
retrier
function, decide in catch, throw if need to retry, and swallow andbail
if needed. But this is a lot of boilerplate and can not be extracted into a separate function.While having a function in option would be much easier.
Did it make sense?
The text was updated successfully, but these errors were encountered: