Skip to content
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

[improvement] allow retryStrategy to be async #107

Open
Hoya opened this issue Jul 15, 2019 · 1 comment
Open

[improvement] allow retryStrategy to be async #107

Hoya opened this issue Jul 15, 2019 · 1 comment

Comments

@Hoya
Copy link

Hoya commented Jul 15, 2019

If the function for retryStrategy is an async function the request will continue to retry even when the request has been successfully executed.

I'm trying to update the proxy settings on retry and I need to pull a new proxy from an API within the retryStrategy function.

@FGRibreau
Copy link
Owner

Maybe a backward-compatible change to the retryStrategy API could be:

function myRetryStrategy(err, response, body, options, cb){
  // retry the request if we had an error or if the response was a 'Bad Gateway'
 cb(!!err || response.statusCode === 502);
}

and then on request-retry-side we wouls have to check for myRetryStrategy.length in order to understand if the function is sync or async :)

I will accept a PR for that :)

@FGRibreau FGRibreau changed the title retryStrategy breaks when function is async [improvement] allow retryStrategy to be async Jul 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants