softonic / axios-retry

Axios plugin that intercepts failed requests and retries them whenever possible
Other
1.9k stars 167 forks source link

feat: Proposal implement onMaxRetryTimesExceeded to allow user to emit a custom error after retries done #237

Closed fabriciomsdev closed 12 months ago

fabriciomsdev commented 1 year ago

Why:

Sometimes we need to treat retry error in HTTP communications as a step of big flow we should follow, for example to classify a http transaction to be retried again by another service in the background.

Solution:

For this reason I am creating the callback onMaxRetryTimesExceeded to be called after the last retry was called. That way we can trigger for example a custom Exception to classify the transaction.

Example of Use:

image
mindhells commented 1 year ago

Very interesting, thanks a lot for your contribution. There's a couple of things to change in the PR though:

mindhells commented 12 months ago

We've just migrated the implementation of this library to typescript Please review my comments and create a new PR if you think this is still relevant Thank you!