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

Is there way to get current attempt number when a retry happens? #92

Closed
ghaisassujit opened this issue Aug 19, 2019 · 3 comments
Closed

Comments

@ghaisassujit
Copy link

Scenario below:

polly().handle((err) => {
// TODO: Log error.
// TODO: Log Retry Attempt number and make some decision based on it.
return true;
})
.waitAndRetry([60000, 1800000, 3600000])
.executeForPromise(() => {return this.doDownload();})

@mauricedb
Copy link
Owner

Hi, I can see that would be useful. Right now only the error is provided as the handle() is meant for deciding what errors to retry and which ones not.

I wil be happy to include a PR that adds it as a second parameter object just like is done with some other functions.

@carmo-evan
Copy link

carmo-evan commented Jan 30, 2020

My workaround:

let retries = 0;
polly().handle((err) => {
    // TODO: Log error.
    // TODO: Log Retry Attempt number and make some decision based on it.
    retries++;
    if (retries > n) {
       // do something
    }
    return true;
})
.waitAndRetry([60000, 1800000, 3600000])
.executeForPromise(() => {return this.doDownload();})

@mauricedb
Copy link
Owner

@carmo-evan

Is the retries counter being reset before a request or after a sucesfull completion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants