Intercept timeout errors?
See original GitHub issueI use interceptors.response.use
to log details about the for every request we do (error or success). It’s very useful to have it in our logs to investigate on issues.
But when we get a timeout error, those interceptors are not invoked so all we get in our logs is:Error: timeout of 3000ms exceeded
Is there some kind of global event or something that I could use to add context to timeout errors?
Context
- axios version: v0.16.2
- Environment: node v8.5.0
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:6
Top Results From Across the Web
Cypress and Flaky Tests: How to Handle Timeout Errors
Flaky Cypress Tests Caused by Timeout Errors ... To accomplish this, start by defining the intercepted route and assigning it an alias.
Read more >Demonstrate a timeout and error HTTP interceptor. - StackBlitz
Demonstrate a timeout and error HTTP interceptor.
Read more >cypress - How to match intercept on response - Stack Overflow
So the test is failing because status is Running, and the expected is Completed. how to increase timeout in this case? cy.intercept('GET', ...
Read more >intercept - Cypress Documentation
Spy and stub network requests and responses. Tip: We recommend you read the Network Requests guide first. All intercepts are automatically cleared before....
Read more >Cypress cy.intercept Problems - Gleb Bahmutov
Imagine you are trying to check how your application handles a network communication error. Internet is unreliable, servers go down and come ...
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
When a timeout happens it will return an error code with the value
ECONNABORTED
https://github.com/axios/axios/blob/b7d8d126dad7341addcd7b063f7b261955ec9152/lib/adapters/xhr.js#L95This is more or less how i do it:
The
ECONNABORTED
code is also used when the request is manually aborted: https://github.com/axios/axios/blob/503418718f669fcc674719fd862b355605d7b41f/lib/adapters/xhr.js#L71 Is there a good way to differentiate between the server request timeouts and manual aborts?We’re not currently using
.abort()
anywhere, so that check works for us for now, but I could see a bug crop up if we later had to add in a manual request cancel and forgot about our assumption of using that code only for the timeout case.