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.

Axios causes node.exe to crash without possibility to catch the exception

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:20 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ahwitzcommented, Nov 16, 2022

Still encountering this with Axios 1.1.3 intermittently in Azure Functions.

1reaction
toninofoxcommented, Feb 7, 2022

I can reproduce the issue on macOS, ubuntu and node 14.18. The same code works on node v16+ throwing the stacktrace below

Error: aborted
    at connResetException (node:internal/errors:691:14)
    at TLSSocket.socketCloseListener (node:_http_client:407:19)
    at TLSSocket.emit (node:events:402:35)
    at node:net:687:12
    at TCP.done (node:_tls_wrap:580:7)
    at TCP.callbackTrampoline (node:internal/async_hooks:130:17)

while in node 14 it fails in the async_hook callbackTrampoline while calling the callback.apply. the cb argument is undefined (asyncId = 0)

function callbackTrampoline(asyncId, resource, cb, ...args) {
  const index = async_hook_fields[kStackLength] - 1;
  execution_async_resources[index] = resource;

  if (asyncId !== 0 && hasHooks(kBefore))
    emitBeforeNative(asyncId);

  let result;
  if (asyncId === 0 && typeof domain_cb === 'function') {
    args.unshift(cb);
    result = domain_cb.apply(this, args);
  } else {
   ==> result = cb.apply(this, args);
  }

  if (asyncId !== 0 && hasHooks(kAfter))
    emitAfterNative(asyncId);

  execution_async_resources.pop();
  return result;
}

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…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Axios causes node.exe to crash without possibility to catch the ...
Axios v.0.21.0 Basic Auth GET-queries causes node.exe to silently crash, without possibility to catch the exception.
Read more >
server crashes after failed axios get request in Node.js
But server crashes if the first axios.get() fails with 400 code when data corresponding to the provided ID doesn't exist. Originally had try...
Read more >
mzabriskie/axios - Gitter
Hi, axios v.0.21.0 causes node.exe to silently crashing, without possibility to catch the exception. Occurs with node.js v.14.15.0 (current LTS Version, ...
Read more >
Let It Crash: Best Practices for Handling Node.js Errors on ...
When a JavaScript error is not properly handled, an uncaughtException is emitted. These suggest the programmer has made an error, and they ...
Read more >
Common errors | npm Docs
Broken npm installation · Random errors · No compatible version found · Permissions errors · Error: ENOENT, stat 'C:\Users\<user>\AppData\Roaming\npm' on Windows 7 ...
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