Skip to content
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

timeoutErrorMessage ignored and no message returned on timeout #2716

Closed
sabinasiddiqi opened this issue Feb 5, 2020 · 2 comments
Closed

Comments

@sabinasiddiqi
Copy link

Describe the bug
While using axios in our application we noticed that it is almost impossible to determine when an axios error is caused by a timeout. The AxiosError is as follows:

{
"config":
{
"url":redacted,
"method":"get",
"headers":{"Accept":"application/json, text/plain, */*"},
"transformRequest":[null],
"transformResponse":[null],
"timeout":2000,
"timeoutErrorMessage":"It appears that we cannot reach the backend system.\nCheck that you are connected to the correct vpn.\n\n"
},
"code":"ECONNABORTED"
}

There is no message in the error json (this might be caused by a scoping error in the enhanceError method here

The response object is undefined so we cannot check the status or statusText or data in the response.

To Reproduce
Code snippet to reproduce, ideally that will work by pasting into something like https://npm.runkit.com/axios, a hosted solution, or a repository that illustrates the issue. If your problem is not reproducible, please file under Support or Usage Question

axios.get(<insert url that will time out>, { timeout: 100, timeoutErrorMessage: 'this request timed out!'}).catch(error=> { 
console.log(error);
console.log(error.toJSON());
console.log(error.code);
console.log(error.stack);
console.log(error.message);
console.log(error.response);
});

Expected behavior
I expect to receive an error code that reflects that this request timed out and receive the timeout error message in the error.message or error.toJSON().message or error.response.data.message.

Environment:

  • Axios Version [e.g. 0.18.0]: 0.19.2
  • OS: [e.g. iOS 12.1.0, OSX 10.13.4]: OSX 10.14.6
  • Browser [e.g. Chrome, Safari]: Chrome
  • Browser Version [e.g. 22]: 79.0.3945.130
  • Additional Library Versions [e.g. React 16.7, React Native 0.58.0]: react 16.12.0

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

@nyel-gh
Copy link

nyel-gh commented Feb 10, 2020

We just recently started to have this problem. Any workaround you did?

@chinesedfan
Copy link
Collaborator

Similar with #2351 and #1543. Currently I have no ideal solution. You should be able to check the message or stack for timeout.

@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants