Closed
Description
Version
19.5.0 and 18.14.0
Platform
Linux ehmicky-laptop 5.19.0-31-generic #32-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 20 15:20:08 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
stream
What steps will reproduce the bug?
import { pipeline, PassThrough, Readable } from 'node:stream'
const stream = Readable.from([])
stream.read()
process.nextTick(() => {
pipeline(stream, new PassThrough(), () => {
console.log('done')
})
})
With Node >=18.14.0 and >=19.5.0, done
is not printed.
With Node <18.4.0 and <19.5.0, done
is printed.
How often does it reproduce? Is there a required condition?
Only the Node.js minor version.
What is the expected behavior?
stream.pipeline()
should fire its callback if the readable stream has already ended.
What do you see instead?
Whether the callback is fired or not depends on the Node.js minor version.
Additional information
It seems like the following PR might be responsible for this new behavior: #46226
Side note: this currently breaks:
get-stream
, which now hangs on streams that have already ended:get-stream
does not complete when the stream has already ended sindresorhus/get-stream#50- Execa, which uses
get-stream
to wait for a child process' stdin/stdout/stderr to complete before completing itself: Promise never resolves if process output pipes are read first in node 18.14.0 sindresorhus/execa#516