Uh oh!
There was an error while loading. Please reload this page.
stream: readable stream continues to read when pushing a empty string - #18211
stream: readable stream continues to read when pushing a empty string#18211MoonBall wants to merge 1 commit into
Conversation
jasnell
commented
Jan 17, 2018
ping @nodejs/streams @mcollina |
mafintosh
commented
Jan 17, 2018
From reading your test I'm not sure I completely understand what the problem is? |
@mafintosh From the view of a nodejs user, I think a readable stream should end if only calling But if |
mcollina
commented
Jan 18, 2018
I am 👎 to this change. |
mafintosh
commented
Jan 18, 2018
Yes, I'm agreeing with @mcollina as well. Stream termination should be as explicit as possible. I think we should consider having an explicit API for it at some point. |
MoonBall
commented
Jan 18, 2018
@mcollina@mafintosh My purpose may be misunderstood. I updated the test so that you can better understand it. I am so sorry for my poor english. |
We can just consider that |
mcollina
commented
Jan 18, 2018
Here are some automated runs: CI: https://ci.nodejs.org/job/node-test-pull-request/12611/ Anyway, if we want to relax this it needs to be done earlier: https://github.com/MoonBall/node/blob/49ed0814f2750075fb64ab167f9a129f70f37d52/lib/_stream_readable.js#L234 esplicitly checks for a string longer than zero. This check was made pretty explicit, so if we want to make this change we should edit it there. I'm not super-confident in adding cc @mafintosh? |
addaleax
commented
Jan 18, 2018
The linter seems to have failed with:
|
MoonBall
commented
Jan 18, 2018
mcollina
commented
Jan 18, 2018
Can you also rebase on top of master? |
MoonBall
commented
Jan 18, 2018
ok. |
eef4179 to
9547febCompareMoonBall
commented
Jan 18, 2018
Rebased. |
mcollina
commented
Jan 19, 2018
What happens if you push |
mcollina
commented
Jan 19, 2018
@mcollina The error is: I doesn't fix it, because I think |
9547feb to
aaf9bc7CompareMoonBall
commented
Jan 22, 2018
@mcollina I modified the code because that |
mcollina
commented
Jan 23, 2018
I'm not super convinced by this change, I'll have more time to review it in a week. @mafintosh can you check this? |
mafintosh
commented
Jan 23, 2018
Let me try and look into it tonight |
BridgeAR
commented
Feb 1, 2018
mcollina
left a comment
There was a problem hiding this comment.
I'm not convinced that changing this is the right thing to do, yet. Maybe somebody else should weight in on why.
BTW, this is semver-major.
mafintosh
commented
Feb 2, 2018
My bad with the tests, was using the wrong branch. They pass. |
mafintosh
commented
Feb 2, 2018
@MoonBall what happens if you do |
MoonBall
commented
Feb 3, 2018
@mafintosh The result is same if I |
There was a problem hiding this comment.
could you collect the chunks in an array and deepEqual those and the end instead of the concatenated string? That'd make it a bit easier for me (and others) to understand and show that it isn't returning an empty string here ever :)
There was a problem hiding this comment.
There is a misunderstanding. This change only fixed that the 'end' event isn't emitted when we push a empty string, a empty buffer or undefined.
There was a problem hiding this comment.
Currently, a readable stream in non-object mode doesn't inform users a empty string or a empty buffer. It is reasonable.
There was a problem hiding this comment.
I'd like it if the test was a bit more explicit.
result += data doesn't tell me if r.read() returns an empty buffer, which from reading the test, you might expect.
Doing result.push(data) and then on end assert.deepEquals(result, [...]) would help
mafintosh
commented
Feb 3, 2018
aaf9bc7 to
29554edCompare29554ed to
77a66d3Comparemcollina
commented
Feb 15, 2018
Landing |
mcollina
commented
Feb 15, 2018
Landed as faeee11. |
PR-URL: #18211 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: nodejs#18211 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
stream