Uh oh!
There was an error while loading. Please reload this page.
stream: 'readable' have precedence over flowing - #18994
Conversation
c2fb53b to
53ef8f2Comparemscdex
commented
Feb 26, 2018
Wouldn't |
mcollina
commented
Feb 26, 2018
@mscdex you are right. I didn't account for https://github.com/nodejs/node/blob/master/lib/events.js#L324-L336. Do you think I can just listen for |
mafintosh
commented
Feb 26, 2018
@mcollina so basically just suspends flowing when readable is set? |
mcollina
commented
Feb 26, 2018
@mafintosh that's the goal yes. It also restores the behavior after |
mafintosh
commented
Feb 27, 2018
@mcollina wondering if we should even fix this. the same behaivor described in the issue would happen if there are two consumers of the readable event anyway (which is what happens in flowing mode). not too much of a fan of implicit event listener side effects |
mcollina
commented
Feb 27, 2018
I am good with not fixing it. But it’s a discussion to have. This fixed a major usability problem if you want to have both a on(‘data’) and on(‘readable’)/read() at the same time (with pipe) read() will always return null. I’m ok if we want to remove the resume side effect when removing ‘readable’, as that might be confusing. However we should really be updating readableListening: this is also a bug without the fix for read() itself. |
mafintosh
commented
Feb 27, 2018
Removing the removeListener stuff but keeping the other part sounds like a good middleway to me 👍 |
BridgeAR
commented
Mar 6, 2018
@nodejs/streams @mafintosh PTAL |
BridgeAR
commented
Mar 6, 2018
mcollina
commented
Mar 7, 2018
@nodejs/tsc what do you think? An alternative approach might be to remove the |
There was a problem hiding this comment.
Yes, they follow the prevailing pattern in this test file. Without the console.log statements, this is undebuggable.
mafintosh
commented
Mar 14, 2018
Lots of good tests! LGTM from me 👍 |
03e66ed to
44fad80Comparemcollina
commented
Mar 14, 2018
mcollina
commented
Mar 14, 2018
Tagging @nodejs/tsc because it is semver-major. |
There was a problem hiding this comment.
Nit: not sure why this was changed and it doesn't really matter but for consistency I would keep the arrow function.
mcollina
commented
Apr 4, 2018
There was a problem hiding this comment.
Can you avoid the line break and capitalize the sentence?
There was a problem hiding this comment.
Might be good to have chunk printed out here as well
There was a problem hiding this comment.
Can you change to comment above this line so that it says why we do this, rather than what we do? I assume it’s about the this.resume() call below?
In Streams3 the 'readable' event/.read() method had a lower precedence than the `'data'` event that made them impossible to use them together. This make `.resume()` a no-op if there is a listener for the `'readable'` event, making the stream non-flowing if there is a `'data'` listener. Fixes: nodejs#18058
mcollina
commented
Apr 4, 2018
@addaleax PTAL |
mcollina
commented
Apr 5, 2018
mcollina
commented
Apr 6, 2018
Landed as cf5f986 |
In Streams3 the 'readable' event/.read() method had a lower precedence than the `'data'` event that made them impossible to use them together. This make `.resume()` a no-op if there is a listener for the `'readable'` event, making the stream non-flowing if there is a `'data'` listener. Fixes: #18058 PR-URL: #18994 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
MylesBorins
commented
Apr 11, 2018
Seems like failures in cf5f986#diff-573b8412079b987e160a3fde511d5b9b are showing up in a couple places In a couple CI runs in #19201 and also in http://github.com/nodejs/node/pull/19924 @mcollina thoughts? |
mcollina
commented
Apr 11, 2018
@MylesBorins We are already tracking it in #19905. |
Caused by nodejs/node#18994Closes#26
In Streams3 the 'readable' event/.read() method had a lower precedence
than the
'data'event that made them impossible to use them together.This make
.resume()a no-op if there is a listener for the'readable'event, making the stream non-flowing if there is a'data'listener.Fixes: #18058
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
stream, http