Skip to content

in transform stream transform method, callback(null, null) doesn't end stream but this.push(null); callback() does #62769

@ShenHongFei

Description

@ShenHongFei

Version

latest main branch

Platform

irrelevant

Subsystem

stream

What steps will reproduce the bug?

https://nodejs.org/api/stream.html#transform-transformchunk-encoding-callback

callback(null, null) doesn't end stream but this.push(null); callback() does

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

callback(null, null) and this.push(null); callback() have the same effect (the stream ends).

What do you see instead?

callback(null, null) is different from this.push(null); callback()

Additional information

https://github.com/nodejs/node/blob/main/lib/internal/streams/transform.js#L177-L179

Would it be possible to change this to the following?

if (val !== undefined) {
  this.push(val)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions