-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to change retry() params from the task? #1001
Comments
Unfortunately, there's no way to change the retry options after the fact right now -- we copy the options to a new object internally. To exit early, you could callback with a null error, and some sort of sentinel object you handle specially, but it's kind of a hack. I'd love to think of a clean way to support customizing the times and interval -- perhaps a function that is called for each iteration to get the times/interval. This would more easily enable things like exponential backoff and early exits. function getNextInterval(prevInterval, remaningTimes, lastError) {
if (prevInterval == null) {
// initial iteration
return {
interval: 100,
times: 5
};
}
if (lastError && lastError.code === "foo") {
// exit early
return {
times: 0
};
}
// exponential backoff
return {
interval: lastInterval * 2,
times: times - 1
};
}
async.times(getNextInterval, worker, done); |
Thanks @aearly! I'll try this eventually and see how it behaves... |
Could we implement the Obviously, if the passed parameter for |
Hmmn, perhaps we could make the retry |
I think the behavior added in #1161 should be good enough for now. |
Hello,
I would like to know if it'd be possible to be able to update the
times
argument of theretry()
from thetask
?For instance, I would like to be able to increase the
interval
value as the attempt count increases or trim down the attempt count to0
when a particular error occurred (in order to avoid unnecessary doomed attempts).Example:
Any idea or workaround?
Thanks,
The text was updated successfully, but these errors were encountered: