-
Notifications
You must be signed in to change notification settings - Fork 168
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
Support retry on 200 response #272
Support retry on 200 response #272
Conversation
473fff5
to
6fc43d3
Compare
Not sure this is a good idea, as axios itself is capable of doing this just providing it with a |
You're right, i realise this can be accomplished using validateStatus together with retryCondition 😭. This change is not required then, and i'll close it. |
|
Please reopen it as your change is very welcomed :) |
Oh right, retryCondition only serves to retry and cannot change whether a response should be resolved or rejected. Using validateStatus will be too general as it rejects solely based on the status code. @mindhells could you take a look again also please? |
My concern was about overlapping functionality with what axios itself provides. This should be a simple library with a very specific purpose, and also there's no big community behind it to be maintained. |
I understand where you're coming from; thank you for helping to maintain the project 🙏 The library right now can handle retrying requests when the response comes back with a status code that is non-2xx. However, as brought up by @matikucharski and in issue #267 , there are cases where we also want to retry when the status code is 2xx. From what I've read from the axios documentation we can use This library is about retrying requests, so for me I think it should also support retrying 2xx status code responses innately. As far as I know, there is no single option in axios that can be set to cover this use case. With this feature, the user should be able to further control when the response should be treated as an error and not an error, thus enabling retrying on 2xx responses too. Would like to know what you think 🙏 |
Makes sense to me, but please sign your commits so I can merge the PR 🙏 |
8c6bbeb
to
e9e7d6f
Compare
@mindhells I have signed the commits now. One more thing that I would like your opinion on (perhaps also @matikucharski) before we merge: should we make If we do this, then the user doesn't need to specify:
|
At this point I'd keep your implementation and give full control to the user. But let's hear others' opinion. Maybe you can ask in the issue as well. |
Done. What you said makes sense too. It's possible to resolve non-2xx responses in axios with |
I agree. I wouldn't prevent users from handling other status codes when response is received. |
@mindhells in that case i think we should be ready to merge? |
published as 4.3.0 |
This solves #267
Before we couldn't retry on any 200 response. This will add functionality that supports retrying for any logic defined by the user.