statusCodesToRetry doesn't work when Http Status Code is 2xx
See original GitHub issueWhen specify statusCodesToRetry as 2xx, this doesn’t work because of the following code:
export function attach(instance?: AxiosInstance) {
instance = instance || axios;
return instance.interceptors.response.use(onFulfilled, onError);
}
onError will be only triggered when the Http Status Code is not 2xx. That means all retries this library will perform only works when Http Status Code is not 2xx.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
HTTP response status codes - MDN Web Docs - Mozilla
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Read more >List of HTTP status codes - Wikipedia
This is a list of Hypertext Transfer Protocol (HTTP) response status codes. Status codes are issued by a server in response to a...
Read more >java - Is checking "http_status / 100 != 2" better than ...
So if you want to handle the condition if the status code is NOT belonging to 2xx, you can do the below: if...
Read more >HTTP Status Codes: All 63 explained - including FAQ & Video
HTTP status codes are three-digit responses from the server to the browser-side request. Everyone has probably gotten the classic 404 page-not-found error.
Read more >Status codes in HTTP - W3C
The data sections of messages Error, Forward and redirection responses may be used to contain human-readable diagnostic information. Success 2xx. These codes ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So to be honest - this is far enough outside the goal of the library, that I don’t want to add support for managing retries on 2xx responses. The interceptor API in axios is good enough that you should be able to plug in there, and lift whatever bits of backoff stuff you need from here. Apologies!
One of the ways we can implement this by not actually implementing this is - In
axios-retry
, we start catching the errors thrown by custom interceptors (request/response) ofaxios
. In this way people can write their own custom interceptors and validate the data the way they want. @JustinBeckwith, Thoughts?