Skip to content

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

Description

@pavelseverov
  • 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)

Activity

  1. jasnell commented on Nov 30, 2020

    @jasnell
    Member

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

  2. pavelseverov commented on Nov 30, 2020

    @pavelseverov
    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?

  3. jasnell commented on Nov 30, 2020

    @jasnell
    Member

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

  4. jasnell commented on Nov 30, 2020

    @jasnell
    Member

    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.

  5. pavelseverov commented on Nov 30, 2020

    @pavelseverov
    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...

  6. pavelseverov commented on Dec 1, 2020

    @pavelseverov
    Author

    @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 :·)))

  7. added
    httpIssues and PRs related to the http subsystem.
    on Dec 6, 2020
  8. aduh95 commented on Dec 7, 2020

    @aduh95
    Contributor

    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);.

  9. ak-s commented on Dec 9, 2020

    @ak-s

    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).

  10. pavelseverov commented on Dec 10, 2020

    @pavelseverov
    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.

  11. aduh95 commented on Dec 11, 2020

    @aduh95
    Contributor

    @pavelseverov do you see anything printed to stderr?

  12. pavelseverov commented on Dec 13, 2020

    @pavelseverov
    Author

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

  13. Bobricko commented on Feb 10, 2021

    @Bobricko
  14. oneslash commented on Mar 5, 2021

    @oneslash

    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)
    
  15. bloodchen commented on Jan 14, 2022

    @bloodchen

    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

  16. iamnafets commented on Jan 16, 2022

    @iamnafets

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

  17. Jaewoook commented on Jan 17, 2022

    @Jaewoook

    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

  18. bloodchen commented on Jan 21, 2022

    @bloodchen

    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.

  19. Bobricko commented on Oct 11, 2022

    @Bobricko
  20. StefanStojanovic commented on Jul 31, 2024

    @StefanStojanovic
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpIssues and PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions