softonic / axios-retry

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

bug?: retry not working #161

Closed roachadam closed 2 years ago

roachadam commented 3 years ago

Not quite sure how this happened, but I'm probably missing something stupid.

Code:

axiosRetry(this.ax, { 
    retries: 3,
    retryCondition: (e) => {
        //return true;
        if(!e.response)
            return false;

        //todo 302
        return e.response.status >=200 && e.response.status <=204;
    }
});

For whatever reason, I make a request with that same ax instance, get a 502 error, and it does not retry. I also uncommented the return true, and it still does not retry.

I thought it could be interfering with my other axios interceptor, but I turned that off and still the same issue persists.

win64 bit node v12.16.1 axios-retry v

schmidlidev commented 2 years ago

This library seems to just... not work? I even tried:

retryCondition: () => true

and could not get this library to ever actually perform a retry. Ended up using https://www.npmjs.com/package/retry-axios instead.

geoffrich commented 2 years ago

I ran into this issue, and for me it was caused by my Axios version. 0.21.2 introduced a bug that 0.21.3 fixed. Updating Axios caused the retries to succeed.

That likely isn't the cause of OP's issue, since they created this issue in February and 0.21.2 was released in September, but wanted to comment in case someone else had the same root cause.