question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

timeout not cleared on error

See original GitHub issue

Summary

When request is made and network error occurs, timeout is not cleared. It should be easy to replicate:

// disconnect from network before running
const axios = require('axios')
axios.get('http://github.com', { timeout: 1000 })

This script should fail and instantly quit but it will rather fail and hang for 1s

Context

  • axios version: 0.18.0
  • Environment: node

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

3reactions
wholegroupcommented, Aug 16, 2018

@JustinBeckwith I have the same issue The issue is that a request is completed in time but then the node process is hanging up during timeout before exiting. I suppose there is some issue with clearTimeout if an exception occurs (at least ENOTFOUND).

Please re-open this issue.

1reaction
cztomsikcommented, Apr 7, 2018

I’ve simply disabled wifi on my macbook, maybe it is platform specific? Also, I had different error.

node test_axios_disconnect.js 

node:61410) UnhandledPromiseRejectionWarning: Error: getaddrinfo ENOTFOUND github.com github.com:80
    at errnoException (dns.js:55:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:97:26)
(node:61410) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:61410) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Read more comments on GitHub >

github_iconTop Results From Across the Web

clearTimeout runs but it is not clearing the setTimeout
The execution enters the if-else condition but the clearTimeout doesn't seem to be working. The execution always refreshes the entire page ...
Read more >
clearTimeout() - Web APIs - MDN Web Docs
The global clearTimeout() method cancels a timeout previously established by calling setTimeout().
Read more >
Timer not clearing. How to properly use setTimeout ... - Reddit
I'm using React Native. I'm just trying to having a message change on the screen after 5 seconds. I understand that if the...
Read more >
Test case is leaking async ops when using clearTimeout ...
If there is an error, the await delay(0) is skipped along with the post metrics, then it continues to the next test getting...
Read more >
How does clearTimeout Works in JavaScript? - eduCBA
This will be the ID that was returned by the setTimeout() function. You can clear the timeout by using this id which identifies...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found