-
Notifications
You must be signed in to change notification settings - Fork 162
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
how to auto-retry after waiting pre-defined time for response #164
Comments
use |
If I am not wrong, |
Here is my solution for using a different non-axios library for requests, you can use it here if you're having issues:
|
Thanks for proposing an alternative solution @KevinDanikowski. I am going to try this out. |
@appukuttan-shailesh sounds good, I would recommend doing research into canceling axios calls, |
I am looking for a solution for this problem, @appukuttan-shailesh did you find any good solution for the problem mentioned? |
Not really. I think the target server performance improved and I stopped getting these issues. So didn't really pursue this further. But I don't think I had arrived at a proper axios based solution. |
I'm just after the very simple behaviour of "retry on timeout". I can't work out how to make this happen. If the network is flaky, some requests just die. Axios eventually times out. This is not a 50x error. It's a timeout. I want to try a few times before giving up. I know that in 99 times out of 100, the second request will succeed. It seems oddly difficult to achieve this. The source SPECIFICALLY excludes network timeouts. Which is different. I'm talking about client-side axios timeouts. eg: I want it to start the get, in 2 seconds, fail that, try again, 2 seconds later try again, 2 seconds later fail |
Found my solution: |
Sadly this does not work currently with axios 1.4.0 or 1.5.0 and axios-retry 3.8.0. The issue is that even if retryCondition is true, for a timeout it does not retry. It works for non-timeout erros.
What did the magic trick for me:
|
I am using axios to make a GET request in my reactjs app. Here is a code snippet of how I am currently making this call:
What I find is that my GET requests work well most of the time, but around one out of 10 times they get stalled and remain in the pending state for a long time. During this time if I refresh the page, and redo the GET request, it works fine and returns a response immediately. This is an issue that I am facing since some time and could be a problem involving the targer server (over which I have no control).
So what I would like to do is the following (based on what I have found to work when doing manually):
So basically what I wish to do is retry, upto N times, if there is no repsonse within 5 seconds each time.
I know that axios-retry can trigger retry on error codes, but not sure if it can do "wait for X seconds for response, else retry". Is this doable? Thanks for any help.
The text was updated successfully, but these errors were encountered: