in transform stream transform method, `callback(null, null)` doesn't end stream but `this.push(null); callback()` does
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
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)
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/internal/streams/transform.js at lines 177-179 and compare the documented Transform callback behavior with the existing stream implementation. Reproduce the difference between callback(null, null) and this.push(null); callback(), then inspect the relevant stream tests. Done means both forms consistently end the stream as described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- stream-processing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100