axios: Axios causes node.exe to crash without possibility to catch the exception
Describe the bug
Axios v.0.21.0 causes node.exe to silently crash, without possibility to catch the exception. Occurs with node.js v.14.15.0 (current LTS Version, recommended for most users). Earlier or later versions works Ok (I have tested v.9.11.1 and v.15.1.0) Update: Node v.9.11.1 also crashing in the similar way (on Windows Server 2016 v.1607) Update 2: Basic Auth causes the crashing. Requests without authorization works ok so far Update 3: Node v.14.15.1 also crashing in the similar way
To Reproduce
Effect is not stable and not easy to be quickly reproduced, appears mostly on bad/slow internet connections. Most probably because of “connect ETIMEDOUT”, but this is only my guessing, because node.exe just unexpectedly terminates, without any additional info.
// This is example code for reproducing the problem. Actually nothing special, just continuously getting lots of data.
// Size of retrieved files is not important (from several kilobytes to several megabytes)
// MyApi is url/config of service-now.com REST API. Unfortunately I can’t share it.
var axios = require('axios');
let n=1;
test();
async function test() {
do {
await axios.get(MyApiUrl,MyApiConfig)
.then(res => console.log(n++, "got "+JSON.stringify(res.data).length+" bytes (node.js "+process.version+")"))
.catch(err => {console.error("ERROR: "+err.message);process.exit()})
} while (true)
};
Expected behavior
Even on more or less normal internet connection node.exe crashes within getting of one or two gigabytes of data (in summary, by portions, not at once). Choosing bad internet connection will bring the same result faster.
Environment
- Axios Version 0.21.0
- Node.js Versions 14.15.0, 14.15.1, v.9.11.1
- OS: Windows 10 v.1909 and 2004, and Windows Server 2016 v.1607
Additional context/Screenshots
N/A
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 21 (5 by maintainers)
Commits related to this issue
- Update dev dependencies - Everything still works as expected. - Remove bundlesize - It still uses libtorb which is deprecated and broken on Win and requires a full suite of build tools ... — committed to timemachine3030/axios by timemachine3030 4 years ago
- Update dev dependencies (#3401) - Everything still works as expected. - Remove bundlesize - It still uses libtorb which is deprecated and broken on Win and requires a full suite of bui... — committed to axios/axios by timemachine3030 4 years ago
- Update dev dependencies (#3401) - Everything still works as expected. - Remove bundlesize - It still uses libtorb which is deprecated and broken on Win and requires a full suite of bui... — committed to mbargiel/axios by timemachine3030 4 years ago
I have same issue. The catch block worked expected but then Node Process crashed with error below. I used
axios.create
and specified thetimeout
configuration. Seems error throw fromsetTimeout
cannot be catched. But I cannot reproduce it locally.Still encountering this with Axios 1.1.3 intermittently in Azure Functions.
I don’t have enough of a reproduction path to open a new issue, but I still run into this problem with axios v0.27.2 on node v16.15.1. I found out that while awaiting my
axios.post
in my caseprocess.on('beforeExit',...)
gets triggered, which is an indication that there’s no crash going on, but that the event loop is just empty. Apparently Axios is doing nothing anymore 😃.Not sure it has anything to do with it, but if I remove
'Accept-Encoding': 'gzip'
from my headers, the problem also disappears.I can reproduce the issue on macOS, ubuntu and node 14.18. The same code works on node v16+ throwing the stacktrace below
while in node 14 it fails in the async_hook callbackTrampoline while calling the callback.apply. the
cb
argument is undefined (asyncId = 0)not sure what happens inside nodejs but that is caused at this point on aborted connection errors as the node16 stacktrace can show. Hope that can help someone else as I spent hours before finding this thread and understanding why my promises were not resolved/rejected…