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

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

Closed
pavelseverov opened this issue Nov 30, 2020 · 19 comments
Closed
Labels
http Issues or PRs related to the http subsystem.

Comments

@pavelseverov
Copy link

pavelseverov commented Nov 30, 2020

  • Version: 9.11.1, 14.15.0, 14.15.1
  • Platform: Windows 10 v.1909 and 2004; Windows Server 2016 v.1607
  • Subsystem: N/A

What steps will reproduce the bug?

Axios v.0.21.0 Basic Auth GET-queries causes node.exe to silently crash, without possibility to catch the exception.
Occurs with node.js v.14.15.1 (current LTS Version), and earlier versions. Later versions (e.g. v.15.1.0) works Ok

// This is example code for reproducing the problem. Actually nothing special, just continuous getting lots of data. 
// Size of retrieved files is not important (from several kilobytes to several megabytes)
var axios = require('axios');
let n=1;
test();
async function test() {
  do {
    await axios.get(ApiUrlWithBasicAuth,ApiConfig)
      .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)
};

How often does it reproduce? Is there a required condition?

Effect is not stable. Occurs on continuous testing. With more or less normal internet connection node.exe crashes within getting of about one or two gigabytes of data (in summary, by portions, not at once). Choosing bad internet connection will bring the same result faster.

I have reproduced this issue at two different independent REST APIs with Basic Auth. Unfortunately I can't share them, because they are private resources. But I can check some other REST API, if someone can share with me Basic Auth-protected one, available for tests.
I have also tried dozens of APIs from https://github.com/public-apis/public-apis. [Un]fortunately they all work fine, I'm not able to reproduce the issue on them. Probably because there are no Basic Auth-protected APIs.

What is the expected behavior?

Running the above code leads to crash of node.exe without possibility to catch the exception.
UPDATE: with %errorlevel%=0

What do you see instead?

N/A

Additional information

Issue has been also reported to Axios developers: axios/axios#3396
(no solution so far)

@jasnell
Copy link
Member

jasnell commented Nov 30, 2020

"crash" here could mean several things. We need a bit more information. Is an error stack trace generated? Is it a seg fault?

@pavelseverov
Copy link
Author

@jasnell , in my example code node.exe just unexpectedly stops working. Without any messages. Without anything that I'm able to detect. I have checked Windows logs, but there is also nothing.

Is it a seg fault?

Sorry, I don't know what it is. Can you suggest some additional tools/configurations to check it?

@jasnell
Copy link
Member

jasnell commented Nov 30, 2020

Immediately after it crashes, enter echo %errorlevel% on the command line and comment here with what it prints.

@jasnell
Copy link
Member

jasnell commented Nov 30, 2020

For details... a "segmentation fault" is a memory error, they occur at the native (c/c++) level of Node.js where there is a bug in Node.js itself. On Linux, when a segfault happens, the operating system is pretty good at telling us about it but on windows it mostly manifests as a "silent crash" --- that is, the Node.js process just exits without any apparent reason.

@pavelseverov
Copy link
Author

@jasnell , thanks for explanations!
Regarding echo %errorlevel% - I should have guessed it myself, sorry :-) I have added it to the test, and run. Waiting for result...

@pavelseverov
Copy link
Author

pavelseverov commented Dec 1, 2020

@jasnell , just got the crash: %errorlevel% = 0
Node.js v.14.15.1, after hundreds of requests, several gigabytes of pulled data, on quite unstable and slow internet connection. Not sure that quality of connection pays any role here, but at least it allows to not load heavily my testing REST APIs too much - they are unaware of their privilege to take part in this great testing :·)))

@targos targos added the http Issues or PRs related to the http subsystem. label Dec 6, 2020
@aduh95
Copy link
Contributor

aduh95 commented Dec 7, 2020

An error code of 0 means Node.js thinks the execution was successful, and that's also the default code when you call process.exit(). My guess is your catch handler is causing that: .catch(err => {console.error("ERROR: "+err.message);process.exit()}). Could specify a non-zero error code there please (such as process.exit(-1))?

Also, please add a catcher to the test call just in case: test().catch(console.error);.

@ak-s
Copy link

ak-s commented Dec 9, 2020

I believe I have the same issue.
node.exe process terminates without any trace.
node.js v12.20.0
axios v0.21.0
Exit code: -1073740791 (0xc0000409)

This never happened until axios was updated (from v0.19.2).

@pavelseverov
Copy link
Author

@aduh95, thanks for suggestions, I did as you recommended, but result is still the same: silent termination of node.exe, with %errorlevel% = 0.
As I wrote before - only Basic Auth-protected APIs causes this effect. I have tried to do the "fake" Basic Auth for the public APIs. Unfortunately this trick doesn't work. The problem requires true Basic Auth.
If anyone can share Basic Auth-protected APIs available for the testing - I can try to run test with it.

@aduh95
Copy link
Contributor

aduh95 commented Dec 11, 2020

@pavelseverov do you see anything printed to stderr?

@pavelseverov
Copy link
Author

@aduh95 when the "silent crashing" occurs neither is printed to STDERR nor to STDOUT

@Bobricko

This comment has been minimized.

@oneslash
Copy link

oneslash commented Mar 5, 2021

This issue is still happening with 14.16, no error can be found, except:

Error: socket hang up
    at connResetException (internal/errors.js:607:14)
    at Socket.socketCloseListener (_http_client.js:443:25)
    at /usr/src/app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:54:19
    at Scope._activate (/usr/src/app/node_modules/dd-trace/packages/dd-trace/src/scope/async_resource.js:47:14)
    at Scope.activate (/usr/src/app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:12:19)
    at Socket.bound (/usr/src/app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:53:20)
    at Socket.emit (events.js:327:22)
    at Socket.EventEmitter.emit (domain.js:467:12)
    at TCP.<anonymous> (net.js:673:12)
    at TCP.callbackTrampoline (internal/async_hooks.js:131:14)

@bloodchen
Copy link

bloodchen commented Jan 14, 2022

I have the same issue after axios.get around 500 to 700 urls. I am using Mac, node 14.12, axios 0.21.1.
I tried to catch the error with
process.on('unhandledRejection', (reason, promise) => {
console.log(reason)
})
process.on('uncaughtException', (reason) => {
console.log(reason)
})
process.on('SIGTERM', signal => {
console.log(Process ${process.pid} received a SIGTERM signal)
process.exit(0)
})

process.on('SIGINT', signal => {
    console.log(`Process ${process.pid} has been interrupted`)
    process.exit(0)
})

but nothing printed

@iamnafets
Copy link

Seem to be hitting this issue as well. Exit code 0, only triggered in an arm64 container on AWS, non-deterministic.

@Jaewoook
Copy link

I have same issue with @bloodchen. I wrote exactly same catch code but nothing happend. I'm working on Intel mac and Node.js 14.18.2, axios 0.24.0

@bloodchen
Copy link

I want to add, in my case it's not related to basic auth. I just did several hundreds normal http get requests and it crashed at around 400-700 calls.

@Bobricko
Copy link

Bobricko commented Oct 11, 2022 via email

@StefanStojanovic
Copy link
Contributor

This issue has been stale for long time and it references old versions of both Node.js and axios. With this in mind I'm going to close this issue. Feel free to reopen it or open a new one if you experience the same issue agaion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

No branches or pull requests