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
For various use cases, you may want to run code after a failed attempt and before the next try. For example:
Want to log errors/warnings whenever a retry is needed or keep a count of how many retries something took on average
Want to do some cleanup after a failed attempt, e.g. clearing caches or closing a socket
You could argue that it could be better to do cleanup in a catch+rethrow at the end of the function being retried, but that's a bit more verbose (compared to encapsulating that boilerplate in the retry API itself). And for the first use case, where you want to log a warning on the second attempt (first retry) but not the first attempt, you have to resort to hacks like keeping a counter value somewhere.
Suggestion: add an option for a callback like beforeRetry which is run immediately before every retry attempt (but not before the very first attempt).
The text was updated successfully, but these errors were encountered:
For various use cases, you may want to run code after a failed attempt and before the next try. For example:
You could argue that it could be better to do cleanup in a catch+rethrow at the end of the function being retried, but that's a bit more verbose (compared to encapsulating that boilerplate in the
retry
API itself). And for the first use case, where you want to log a warning on the second attempt (first retry) but not the first attempt, you have to resort to hacks like keeping a counter value somewhere.Suggestion: add an option for a callback like
beforeRetry
which is run immediately before every retry attempt (but not before the very first attempt).The text was updated successfully, but these errors were encountered: