Closed
Description
Version
v18.10.0
Platform
Microsoft Windows NT 10.0.19044.0 x64
Subsystem
No response
What steps will reproduce the bug?
I have created repository with failing test case - https://github.com/pavelhoral/node-duplexify-issue that can be cloned and run:
import { Duplex, PassThrough, Readable, Transform } from 'node:stream';
describe('Duplex.from({ writable, readable })', () => {
it('flushes stream after filling buffer', async () => {
// Simple pass-through as a placeholder for more complex setup
const through = new PassThrough({ objectMode: true });
// Stream prepared values, pipe through simple duplex and async transformer for backpressure
const stream = Readable.from(['foo', 'bar'], { objectMode: true })
.pipe(Duplex.from({
writable: through,
readable: through
}))
.pipe(new Transform({
objectMode: true,
highWaterMark: 1, // Setting 1 to force backpressure after a single item
transform(chunk, encoding, callback) {
setTimeout(() => callback(null, chunk), 0);
}
}));
// This never finishes when high water mark is reached
const result = await stream.toArray();
expect(result).toEqual(['foo', 'bar']);
});
});
How often does it reproduce? Is there a required condition?
The issue happens every time in my test case when the internal buffers are full and read must be paused (I guess this condition must happen - https://github.com/nodejs/node/blob/v18.10.0/lib/internal/streams/duplexify.js#L350).
What is the expected behavior?
Stream should correctly finish processing after read buffers are free again.
What do you see instead?
Duplex stream never correctly resumes its operation after the read has to pause.
Additional information
No response