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

uncaughtException from steam's end callback #3941

Closed
bmrpatel opened this issue Aug 8, 2021 · 0 comments · Fixed by #3967
Closed

uncaughtException from steam's end callback #3941

bmrpatel opened this issue Aug 8, 2021 · 0 comments · Fixed by #3967

Comments

@bmrpatel
Copy link

bmrpatel commented Aug 8, 2021

Describe the bug

axios.get(url) is never returning the response when the following error occurs. It should have rejected the promise internally so that caller will get an exception. This issue is raised all the way to the process.on("uncaughtException"... I checked the http.js file line 251. I think if node throws an error here the settle will never be called. Do we need try-catch for the stream.end callback?

RangeError: Array buffer allocation failed
at new ArrayBuffer ()
at new Uint8Array ()
at new FastBuffer (internal/buffer.js:956:5)
at createUnsafeBuffer (buffer.js:152:12)
at allocate (buffer.js:419:10)
at Function.allocUnsafe (buffer.js:384:10)
at Function.concat (buffer.js:564:25)
at IncomingMessage.handleStreamEnd (/home/posintg/verifone-21.06.30/node_modules/axios/lib/adapters/http.js:251:37)
at IncomingMessage.emit (events.js:387:35)
at endReadableNT (internal/streams/readable.js:1317:12)

To Reproduce

It is hard to reproduce. You would have to cause exception at line below

stream.on('end', function handleStreamEnd() {
    var responseData = Buffer.concat(responseBuffer); //error is thrown here
    if (config.responseType !== 'arraybuffer') {
      responseData = responseData.toString(config.responseEncoding);
      if (!config.responseEncoding || config.responseEncoding === 'utf8') {
        responseData = utils.stripBOM(responseData);
      }
    }

    response.data = responseData;
    settle(resolve, reject, response);
  });
// Example code here
 const response = await axios.get(url);
// Example code here
 const response = await axios.get(url);

Expected behavior

Should reject the promise and so caller would be able to handle it.

Environment

  • Axios Version 0.21.1
  • Adapter HTTP
  • Browser n/a
  • Browser Version n/a
  • Node.js Version 14.17.2
  • OS: Debian 10
  • Additional Library Versions: n/a

Additional context/Screenshots

none

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

Successfully merging a pull request may close this issue.

2 participants
@bmrpatel and others