-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
uncaughtException from steam's end callback #3941
Description
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