Closed
Description
The following snipped could cause an internal assertion to fail and an error to be emitted twice:
const https = require('https');
const fs = require('fs');
const path = require('path');
var file = fs.createWriteStream(path.resolve(__dirname, "test"));
https.get(URL, function(response) {
response.pipe(file);
file.on("finish", function() {
file.close();
console.log("Download complete");
});
}).on("error", function(err) {
console.error(err);
});
Error: Parse Error: Expected HTTP/
at HTTPParser.execute (<anonymous>)
at TLSSocket.socketOnData (_http_client.js:509:22)
at TLSSocket.emit (events.js:315:20)
at TLSSocket.Readable.read (internal/streams/readable.js:519:10)
at TLSSocket.Socket.read (net.js:625:39)
at flow (internal/streams/readable.js:992:34)
at resume_ (internal/streams/readable.js:973:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
bytesParsed: 5381,
code: 'HPE_INVALID_CONSTANT',
reason: 'Expected HTTP/',
rawPacket: <Buffer 76 5e f0 68 d0 0c 11 d7 50 8f 67 2e 18 c8 b3 a6 ac c8 75 70 2b e3 65 26 5d e9 b5 1f 6e 62 2b 88 87 15 0e 2f 14 4b 7d 90 33 6a 5a 18 06 bf 74 86 cf 6c ... 16334 more bytes>
}
internal/assert.js:14
throw new ERR_INTERNAL_ASSERTION(message);
^
Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
at assert (internal/assert.js:14:11)
at TLSSocket.socketOnData (_http_client.js:507:3)
at TLSSocket.emit (events.js:315:20)
at TLSSocket.Readable.read (internal/streams/readable.js:519:10)
at TLSSocket.Socket.read (net.js:625:39)
at flow (internal/streams/readable.js:992:34)
at resume_ (internal/streams/readable.js:973:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'ERR_INTERNAL_ASSERTION'
}
v14.16.0 linux arm
Originally posted by @terreng in #35384 (comment)