superagent icon indicating copy to clipboard operation
superagent copied to clipboard

Support tail off delay in retry

Open ungrim97 opened this issue 4 years ago • 3 comments

Often when retrying a request it is useful to have a throttle back on the time between requests to prevent hitting the remote server in quick succession, but also to allow some time for potential issues to resolve.

I can see two potential ways that this could be easily handled in the .retry() function.

  1. Accept an array of intervals in ms similar to the interface for superagent-retyr-delay. Each interval would be applied per request in order

  2. Support the returing of promises in the callback function passed to retry. This would allow much greater scope for functionionality including the ability for the user to await some timeout before returning true/false.

The later is my preferred option, but returning Promises in callbacks is a bit...urgh.

I believe I can implement either option as a PR if desired.

ungrim97 avatar Sep 15 '21 07:09 ungrim97

There seems to have been an attempt to implement async/await for retry: https://github.com/visionmedia/superagent/pull/1527

margarita-lukjanska-cko avatar Oct 05 '21 14:10 margarita-lukjanska-cko

Looks like that PR got merged which will solve the issue I was having so I will close this issue

ungrim97 avatar Jan 07 '22 18:01 ungrim97

On second parse, it seems that the PR in #1527 were reverted so this ticket still needs to be open

ungrim97 avatar Feb 01 '22 15:02 ungrim97