Version
v24.22.0, also on main (e8c279d731f)
Platform
Darwin 27.2.0 arm64
Subsystem
stream
What steps will reproduce the bug?
'use strict';
const { Readable } = require('node:stream');
const chunks = ['a', 'b'];
const stream = new Readable({
highWaterMark: 0,
construct(callback) {
setImmediate(callback);
},
read() {
this.push(chunks.length ? chunks.shift() : null);
},
});
let done = false;
stream.toArray().then((data) => {
done = true;
console.log('done', data.map(String));
});
process.on('exit', () => {
if (!done) console.log('toArray() never resolved');
});
How often does it reproduce? Is there a required condition?
Always, when a Readable has construct() and highWaterMark: 0, and it is consumed with read() (toArray(), for await, a 'readable' listener). Sync and async construct() both hang. Flowing mode ('data') works.
What is the expected behavior? Why is that the expected behavior?
done [ 'a', 'b' ], the same as without construct(). With highWaterMark: 1 it resolves too.
What do you see instead?
toArray() never resolved. is never called.