-
Notifications
You must be signed in to change notification settings - Fork 161
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 Axios Network Error properly detected? #138
Comments
I think we're seeing the same thing. The
This object is of type function errorIsAxiosError(error: Error): error is AxiosError {
return !!(error as any).isAxiosError;
}
function simpleNetworkErrorCheck(error: Error) {
if (errorIsAxiosError(error) && error.message === 'Network Error') {
return true;
} else {
return isNetworkOrIdempotentRequestError(error);
}
}
axiosRetry(axios, { retryCondition: simpleNetworkErrorCheck }); I'm unsure of whether all browsers and platforms will give us that generic "Network Error" message, so I'll check more but it would be great if anyone tries this out and wants to report their findings. |
I think this is because of isRetryAllowed, where ENETUNREACH is in the denylist https://github.com/sindresorhus/is-retry-allowed/blob/master/index.js |
Seems related to axios/axios#2351 I did something similar as above here, but instead check for: const isNetworkError = (error: AxiosError) =>
error && // just to make sure
!error.response && // if there is a response, it reached the server and not a network error
error.code !== 'ECONNABORTED'; // check that it isn't a timeout And then my const retryCondition = (error: AxiosError) =>
isNetworkError(error) || // my custom check
isIdempotentRequestError(error); // retry lib check It's not a perfect network error check, but I'd prefer that to checking for a string message. Ideally this lib should handle it better? |
Axios does set an |
Well. It got a AxiosError about 14 months ago. |
Hi,
I was trying this library to make the app more resilient against possible failed requests because of network errors, and the thing is I am not sure if the default function to detect the network error will work with the current Axios implementation:
when Axios wants to raise the Network Error it sends a null response code:
but in the axios-retry, it will check if there is actually an error code:
maybe theres is something I am missing, but is this really working as expected?
The text was updated successfully, but these errors were encountered: