Update docs: read() required before readable event#4720
Update docs: read() required before readable event#4720wanderview wants to merge 1 commit intonodejs:masterfrom
Conversation
This is one possible fix for nodejs#4695.
|
@isaacs is it really the way it should be documented? Feels really odd to me. |
|
I agree its a bit clunky, but that seems how it operates now. @TooTallNate indicated in #4695 that there is a performance issue with an implicit Perhaps we could default to the more intuitive behavior where the first var r = new Readable({explicitRead: true}); |
|
I guess there is another more complex design problem behind this. If you'll miss 'readable' event - you won't know that it has happened. And this is a situation that was always happening with streams before streams2, so you should explicitly start reading from stream to get first |
|
And, considering this, this pull request LGTM. |
|
As of v0.9.11, my original test no longer fails. At least for streams that has |
When a readable listener is added, call read(0) so that data will flow in, up to the high water mark. Otherwise, it's somewhat confusing that you have to listen for readable, and ALSO call read() (when it will certainly return null) just to get some data out of the stream. See: nodejs#4720
When a readable listener is added, call read(0) so that data will flow in, up to the high water mark. Otherwise, it's somewhat confusing that you have to listen for readable, and ALSO call read() (when it will certainly return null) just to get some data out of the stream. See: #4720
This is one possible fix for #4695.