New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stream.end doesn't send the last chunk on node 16 #38735
Comments
Could you provide a minimal runnable repo? |
We were using a discontinued library called Highland and I replaced it with the following code which fixes the issue in Node 16. But now it is broken in Node 14. What am I missing in here, do you have any clue @Ayase-252 ? function listStuff (ctx) {
ctx.setStatus('foo', 'bar')
const readable = new Stream.Readable({ objectMode: true, read () { return true } })
const writable = new Stream.Writable({ objectMode: true })
writable._write = (data, encoding, done) => done()
readable.pipe(writable)
readable.on('end', () => ctx.call.end({ bar: 'biz' }))
ctx.res = readable
getArrayData().map(i => readable.push({ message: i.message.toUpperCase() }))
readable.push(null) // end readable stream by sending a null chunk
} |
It seems that on Node 16 |
I'm sorry, I don't have idea about it. I tried to recreate the issue by removing unrelated logic with stream, as following const Stream = require('stream')
function getArrayData() {
return ['1', '2', '3']
}
const readable = new Stream.Readable({ objectMode: true, read () { return true } })
const writable = new Stream.Writable({ objectMode: true })
writable._write = (data, encoding, done) => done()
readable.pipe(writable)
readable.on('end', () => console.log("end"));
getArrayData().map(i => readable.push({ message: i.toUpperCase() }))
readable.push(null) // end readable stream by sending a null chunk Then running it with Node.js v14.17.0. It shows that readable is ended by
Did I miss some critical parts? |
For Mac: Darwin Yagizs-MacBook-Pro.local 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 arm64
For Linux: Refer to Github CI tests from refactor: remove p-map malijs/mali#259
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
It has a consistent behavior.
What is the expected behavior?
It should work as expected as with Node 14
What do you see instead?
The following test succeeds on Node 14 but fails on 16.
Additional information
Please refer to my pull request on Mali malijs/mali#259 to see the Github CI output of Node 14 and 16.
The text was updated successfully, but these errors were encountered: