Skip to content

Stream.pipeline() does not call its callback if the readable stream has ended since 19.5.0 #46595

Closed
@ehmicky

Description

@ehmicky

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    streamIssues and PRs related to the stream subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions