Closed
Description
- Version: v15.14.0
- Platform: Linux c501ub 5.8.0-48-generic npm install is unbelievably slow, fails in certain environments #54-Ubuntu SMP Fri Mar 19 14:25:20 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
- Subsystem: stream
What steps will reproduce the bug?
I had a ERR_INTERNAL_ASSERTION when trying to run our application using node 15.x, for a stream destroy test. This code is the minimal version to reproduce it.
The code works ok on node 14.16.1, but fails under node 15.14.0
'use strict';
const {pipeline: pipelineCb, Writable, Readable} = require('stream');
const util = require('util');
const pipeline = util.promisify(pipelineCb);
(async () => {
// Create a dummy readable stream
let i = 0;
const readable = new Readable({
objectMode: true,
read () {
this.push({counter: i++});
}
});
// Create a dummy writable stream with backpressure
const writable = new Writable({
objectMode: true,
write: (chunk, encoding, callback) => {
setTimeout(callback, 10); // Backpressure
}
});
// Pipeline the sql stream in the dummy writable stream & destroy the writable stream after a few ms
try {
await Promise.all([
pipeline(readable, writable),
(async () => {
// Destroy the stream after a few element
// pipeline will destroy all the streams
await new Promise(resolve => setTimeout(resolve, 50));
writable.destroy();
})()
]);
} catch (e) {
if (e.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
throw e;
}
}
})().catch(e => {
console.error(e);
process.exitCode = 1;
});
To reproduce (under node 15):
% node index.js
node:internal/assert: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 new NodeError (node:internal/errors:329:5)
at assert (node:internal/assert:14:11)
at Writable.destroy (node:internal/streams/writable:851:5)
at Object.destroyer (node:internal/streams/destroy:365:59)
at node:internal/streams/pipeline:73:17
at finish (node:internal/streams/pipeline:159:23)
at node:internal/util:408:5
at node:internal/streams/pipeline:74:5
at finish (node:internal/streams/pipeline:159:23)
at node:internal/util:408:5 {
code: 'ERR_INTERNAL_ASSERTION'
}
Expected behavior (under node14):
% node index.js
<no output>