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 #3396

Closed
pavelseverov opened this issue Nov 10, 2020 · 21 comments
Closed

Comments

@pavelseverov
Copy link

pavelseverov commented Nov 10, 2020

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

@timemachine3030
Copy link
Contributor

timemachine3030 commented Nov 11, 2020

@pavelseverov Thanks for the report. I'll try to reproduce. What version of windows did you encounter this on and did you install node from nvm or the binary download? (Edit: I see the Windows version is Windows 10 1909)

I don't know if the Windows version and install method will make a difference but might help me reproduce.

@timemachine3030
Copy link
Contributor

@pavelseverov

Please try this test to see if the issue is reproduced: https://github.com/timemachine3030/axios/blob/bug/3396/test/unit/regression/3396.js

I was able to transfer 3Gb without issue. You can adjust the latency by changing the setTimeout value.

Tested on Window 10 Pro 64-bit, build 19041.572 (running in a Virtual Machine)

@pavelseverov
Copy link
Author

pavelseverov commented Nov 11, 2020

@timemachine3030 thank you for reply!
Update: today I got the same issue on node v.9.11.1 on the different machine: Windows Server 2016 v.1607.
Co currently only node v.15.1.0 remains above suspicion :-)

did you install node from nvm or the binary download?

I have installed node from node-v14.15.0-x64.msi
For testing different versions I'm just saving node.exe from appropriate archive (e.g. node-v15.1.0-win-x64.zip) to working folder and run it as usual. For node v.15.1.0 this approach is working fully Ok.

Please try this test to see if the issue is reproduced: https://github.com/timemachine3030/axios/blob/bug/3396/test/unit/regression/3396.js

Am I right that I need to:

  1. download code from https://github.com/timemachine3030/axios/tree/bug/3396
  2. run npm install
  3. cd to test\unit\regression
  4. run node 3396.js

Unfortunately npm install fails (see the npm_install.log). Maybe you can share the axios-bug-3396 folder with node_modules already installed?
With current, incomplete, node_modules I got the following result of running node 3396.js - node_3396.log

@timemachine3030
Copy link
Contributor

timemachine3030 commented Nov 11, 2020

You have the correct steps. Your install log shows a failure building iltorb. It is a dependency of bundlesize. The easiest way to work around the issue is to remove the "bundlesize" line from the package.json and npm install again.

Use mocha to run the test:
.\node_modules\.bin\mocha.cmd .\test\unit\regression\3396.js --no-timeouts

(Edit: you need to use mocha.cmd in Power Shell to prevent the 'Execution_Policies' error)

timemachine3030 added a commit to timemachine3030/axios that referenced this issue Nov 12, 2020
  - 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 on Mac. Keeping it in the
      package makes it difficult for anyone filing issues to run tests.
    - See: axios#3396
  - Update grunt and it's plugins
  - Update karma to v4...so much faster!
    - Changed the karma config. Better changes: axios#3394
  - Update Webpack
    - Uses terser over uglify
  - Update eslint
    - Caused an error in util.js from the `global` directive so the
      directive is removed (it was not needed).
  - Update typescript
    - The old version of tsc didn't know about new features in
      @types/node (like `asserts value`).
@pavelseverov
Copy link
Author

@timemachine3030

I was able to transfer 3Gb without issue. You can adjust the latency by changing the setTimeout value

Do you mean this code?: setTimeout(() => {send(null, data)}, 10);
I have tried run the test with 0, 1, 100. All is working fine, no crashes or errors.

I have suspicion that problem is in queried API. I have tried many free REST API resources, but can't reproduce the error.
While with https://*.service-now.com/api/... node crashing is still happened, at least sometimes.
Trying currently to find a way to share it with you.

@pavelseverov
Copy link
Author

@timemachine3030,
In my tests I'm starting using timeout in the axios config (e.g. to 10 minutes). Normally it is working fine, but sometimes axios.get ignores it (hangs forever, as if timeout is unlimited). Can it be considered as an issue of axios? Please note - I'm specially using weak internet connection, slow and unstable.

@timemachine3030
Copy link
Contributor

@pavelseverov Regarding timeouts; the config.timeout value is only for the initial connection to the remote. Once the data transfer starts the timeout will not fire.

If you want to cancel a request after the handshake connection and during data transfer I would suggest looking in the docs at how CancelToken works.

@pavelseverov
Copy link
Author

@timemachine3030
I have managed to reproduce the issue with the other source of data. The common with the previous is that both require Basic Auth. Unfortunately I also can't share it with you, because it is private resource. Do you have Basic Auth-protected REST API available for testing? I can check it if you will share it with me.
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.

@pavelseverov
Copy link
Author

@pavelseverov
Copy link
Author

@timemachine3030
Just have reproduced this issue on Node.js 14.15.1, the current "Latest LTS Version".
Going to report it to https://github.com/nodejs/node/issues as well...

jasonsaayman added a commit that referenced this issue Dec 16, 2020
- 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 on Mac. Keeping it in the
      package makes it difficult for anyone filing issues to run tests.
    - See: #3396
  - Update grunt and it's plugins
  - Update karma to v4...so much faster!
    - Changed the karma config. Better changes: #3394
  - Update Webpack
    - Uses terser over uglify
  - Update eslint
    - Caused an error in util.js from the `global` directive so the
      directive is removed (it was not needed).
  - Update typescript
    - The old version of tsc didn't know about new features in
      @types/node (like `asserts value`).

Co-authored-by: Jay <jasonsaayman@gmail.com>
@kepikoi
Copy link

kepikoi commented Apr 22, 2021

Occasionally experiencing the same issue on a Windows hosted Azure Function App (serverless node.js) executing 0.21.1 Axios calls to a private JSON RPC (no basic auth)

D:\home\site\wwwroot>node -v
v12.21.0

D:\home\site\wwwroot>ver

Microsoft Windows [Version 10.0.14393]

Functions process dies with node exited with code -1073740791

Microsoft.Azure.WebJobs.Host.FunctionInvocationException:
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithLoggingAsync>d__20.MoveNext (Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.csMicrosoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 326)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryExecuteAsync>d__15.MoveNext (Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.csMicrosoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 94)
Inner exception Microsoft.Azure.WebJobs.Script.Workers.WorkerProcessExitException handled at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw:
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Script.Description.WorkerFunctionInvoker+<InvokeCore>d__8.MoveNext (Microsoft.Azure.WebJobs.Script, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script\Description\Workers\WorkerFunctionInvoker.csMicrosoft.Azure.WebJobs.Script, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 93)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Script.Description.FunctionInvokerBase+<Invoke>d__24.MoveNext (Microsoft.Azure.WebJobs.Script, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script\Description\FunctionInvokerBase.csMicrosoft.Azure.WebJobs.Script, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 82)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Script.Description.FunctionGenerator+<Coerce>d__3`1.MoveNext (Microsoft.Azure.WebJobs.Script, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script\Description\FunctionGenerator.csMicrosoft.Azure.WebJobs.Script, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 225)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2+<InvokeAsync>d__10.MoveNext (Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.csMicrosoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 52)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<InvokeWithTimeoutAsync>d__27.MoveNext (Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.csMicrosoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 555)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithWatchersAsync>d__26.MoveNext (Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.csMicrosoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 501)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithLoggingAsync>d__20.MoveNext (Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.csMicrosoft.Azure.WebJobs.Host, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 279)

Unfortunately I was not yet able to reproduce this locally

@JeremyDOwens
Copy link

JeremyDOwens commented Aug 15, 2021

Here's a reproduction of a silent, uncaught failure that returns 0:

node-playground % cat axios-silent-fail.js 
const axios = require('axios');

const func = async () => {
  const instance = axios.create({
    timeout: 15000,
    baseURL: 'https://tjrwrestling.net/wp-json/wp/v2/posts',
    headers: {
      'Content-Type': 'application/json',
    },
  });
  const qs = '?per_page=100&orderby=modified&order=desc&modified_after=2021-05-14T00:00:00Z&page=1';
  await instance.get(qs).catch(err => console.log(err));
}

(func().then(() => console.log('success')));
node-playground % node axios-silent-fail.js 
node-playground % node --version
v14.8.0
node-playground %

Axios version = 0.21.1
This succeeds if the per_page value is set to 15. I think it has something to do with incomplete JSON being returned with larger sets.

@aaronadamsCA
Copy link

Giving this a bump because we just started running into the exact same Node.js crash on Azure Functions this week. It's intermittent and hard to reproduce, but happening often enough that we've begun to investigate.

$ yarn why axios
├─ analytics-node@npm:5.1.0
│  └─ axios@npm:0.21.4 (via npm:^0.21.4)
│
├─ auth0@npm:2.36.2
│  └─ axios@npm:0.21.4 (via npm:^0.21.3)
│
└─ jwks-rsa@npm:1.12.3
   └─ axios@npm:0.21.4 (via npm:^0.21.1)

Nothing's really changed in our environment; Node.js v14 on Azure Functions runtime v3, a few dependency patch releases but nothing remotely significant. Axios bumped from 0.21.1 a few weeks ago but that doesn't seem to correlate with when these crashes started.

We can investigate logs etc, just need to know if there's any added info we could provide that might come in handy.

@kevindigo
Copy link

kevindigo commented Oct 28, 2021

We have also been hitting this (or a related/similar) problem in one of our tools.

I just tried the sample reproduction code posted by @JeremyDOwens. With my default dev environment (Ubuntu 20.10, node 14.18.1), it fails silently with per_page set to 100 or 15, but succeeds when it is set to 1.

However, with node 16.13.0, it exits cleanly even with per_page at 100: It logs "success", after logging an error. So perhaps this was fixed in node 16.

[kesmith@kesmith axios-silent-failure]$ node silent.js
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) {
code: 'ECONNRESET',
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: [Function: httpAdapter],
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 15000,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
validateStatus: [Function: validateStatus],
headers: {
Accept: 'application/json, text/plain, /',
'Content-Type': 'application/json',
'User-Agent': 'axios/0.24.0'
},
baseURL: 'https://tjrwrestling.net/wp-json/wp/v2/posts',
method: 'get',
url: '?per_page=100&orderby=modified&order=desc&modified_after=2021-05-14T00:00:00Z&page=1',
data: undefined
},
request: <ref *1> ClientRequest {
_events: [Object: null prototype] {
abort: [Function (anonymous)],
aborted: [Function (anonymous)],
connect: [Function (anonymous)],
error: [Function (anonymous)],
socket: [Function (anonymous)],
timeout: [Function (anonymous)],
prefinish: [Function: requestOnPrefinish]
},
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: true,
socket: TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
secureConnecting: false,
_SNICallback: null,
servername: 'tjrwrestling.net',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object: null prototype],
_eventsCount: 11,
connecting: false,
_hadError: false,
_parent: null,
_host: 'tjrwrestling.net',
_readableState: [ReadableState],
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Circular *1],
timeout: 15000,
write: [Function: writeAfterFIN],
[Symbol(res)]: null,
[Symbol(verified)]: true,
[Symbol(pendingSession)]: null,
[Symbol(async_id_symbol)]: 3,
[Symbol(kHandle)]: null,
[Symbol(kSetNoDelay)]: false,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: Timeout {
_idleTimeout: -1,
_idlePrev: null,
_idleNext: null,
_idleStart: 1084,
_onTimeout: null,
_timerArgs: undefined,
_repeat: null,
_destroyed: true,
[Symbol(refed)]: false,
[Symbol(kHasPrimitive)]: false,
[Symbol(asyncId)]: 12,
[Symbol(triggerId)]: 7
},
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kBytesRead)]: 32768,
[Symbol(kBytesWritten)]: 266,
[Symbol(connect-options)]: [Object],
[Symbol(RequestTimeout)]: undefined
},
_header: 'GET /wp-json/wp/v2/posts/?per_page=100&orderby=modified&order=desc&modified_after=2021-05-14T00:00:00Z&page=1 HTTP/1.1\r\n' +
'Accept: application/json, text/plain, /\r\n' +
'Content-Type: application/json\r\n' +
'User-Agent: axios/0.24.0\r\n' +
'Host: tjrwrestling.net\r\n' +
'Connection: close\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: Agent {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object: null prototype],
requests: [Object: null prototype] {},
sockets: [Object: null prototype] {},
freeSockets: [Object: null prototype] {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
scheduling: 'lifo',
maxTotalSockets: Infinity,
totalSocketCount: 0,
maxCachedSessions: 100,
_sessionCache: [Object],
[Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'GET',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/wp-json/wp/v2/posts/?per_page=100&orderby=modified&order=desc&modified_after=2021-05-14T00:00:00Z&page=1',
_ended: false,
res: IncomingMessage {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
socket: [TLSSocket],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: false,
rawHeaders: [Array],
rawTrailers: [],
aborted: true,
upgrade: false,
url: '',
method: null,
statusCode: 200,
statusMessage: 'OK',
client: [TLSSocket],
_consuming: true,
_dumped: false,
req: [Circular *1],
responseUrl: 'https://tjrwrestling.net/wp-json/wp/v2/posts/?per_page=100&orderby=modified&order=desc&modified_after=2021-05-14T00:00:00Z&page=1',
redirects: [],
[Symbol(kCapture)]: false,
[Symbol(kHeaders)]: [Object],
[Symbol(kHeadersCount)]: 30,
[Symbol(kTrailers)]: null,
[Symbol(kTrailersCount)]: 0,
[Symbol(RequestTimeout)]: undefined
},
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'tjrwrestling.net',
protocol: 'https:',
_redirectable: Writable {
_writableState: [WritableState],
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
_options: [Object],
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 0,
_requestBodyBuffers: [],
_onNativeResponse: [Function (anonymous)],
_currentRequest: [Circular *1],
_currentUrl: 'https://tjrwrestling.net/wp-json/wp/v2/posts/?per_page=100&orderby=modified&order=desc&modified_after=2021-05-14T00:00:00Z&page=1',
_timeout: null,
[Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
accept: [Array],
'content-type': [Array],
'user-agent': [Array],
host: [Array]
}
},
response: undefined,
isAxiosError: true,
toJSON: [Function: toJSON]
}
success
[kesmith@kesmith axios-silent-failure]$

mbargiel pushed a commit to mbargiel/axios that referenced this issue Jan 27, 2022
- 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 on Mac. Keeping it in the
      package makes it difficult for anyone filing issues to run tests.
    - See: axios#3396
  - Update grunt and it's plugins
  - Update karma to v4...so much faster!
    - Changed the karma config. Better changes: axios#3394
  - Update Webpack
    - Uses terser over uglify
  - Update eslint
    - Caused an error in util.js from the `global` directive so the
      directive is removed (it was not needed).
  - Update typescript
    - The old version of tsc didn't know about new features in
      @types/node (like `asserts value`).

Co-authored-by: Jay <jasonsaayman@gmail.com>
@toninofox
Copy link

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

@jasonsaayman
Copy link
Member

Hi 👋

Please could you retry with the latest version and open a new issue should this error still be relevant?

Thanks

@everhardt
Copy link

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 case process.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.

@everhardt
Copy link

I tried the same request that causes node to exit in curl (verbose) and that ends with:

* transfer closed with outstanding read data remaining
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, close notify (256):
curl: (18) transfer closed with outstanding read data remaining

@ahwitz
Copy link

ahwitz commented Nov 16, 2022

Still encountering this with Axios 1.1.3 intermittently in Azure Functions.

@AlexandrGuk
Copy link

AlexandrGuk commented Nov 24, 2022

The error is still repeating.
Node.js v18.4.0
Axios 1.2.0

Example code:

async function createRequest(options) {
    try {
        let response = await axios(options);
        return response;
    } catch (e) {
        console.log(e);
        return null;
    }
}

The console outputs an error from the catch block, but then Nodejs crashes with "UnhandledPromiseRejection" error

@Alivers
Copy link

Alivers commented Jan 30, 2023

The error is still repeating. Node.js v18.4.0 Axios 1.2.0

Example code:

async function createRequest(options) {
    try {
        let response = await axios(options);
        return response;
    } catch (e) {
        console.log(e);
        return null;
    }
}

The console outputs an error from the catch block, but then Nodejs crashes with "UnhandledPromiseRejection" error

I have same issue. The catch block worked expected but then Node Process crashed with error below.
I used axios.create and specified the timeout configuration. Seems error throw from setTimeout cannot be catched. But I cannot reproduce it locally.

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
Error: timeout of 10000ms exceeded
    at createError (/workspace/api-service/srv/main.cjs:87147:20)
    at RedirectableRequest.handleRequestTimeout (/workspace/api-service/srv/main.cjs:87815:20)
    at RedirectableRequest.emit (node:events:513:28)
    at Timeout.<anonymous> (/workspace/api-service/srv/main.cjs:64949:17)
    at listOnTimeout (node:internal/timers:564:17)
    at process.processTimers (node:internal/timers:507:7) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests