-
Notifications
You must be signed in to change notification settings - Fork 7.3k
stream: only end reading on null, not undefined #7856
Conversation
The [Stream documentation for .push](http://nodejs.org/api/stream.html#stream_readable_push_chunk_encoding) explicitly states multiple times that null is a special cased value that indicates the end of a stream. It is confusing and undocumented that undefined *also* ends the stream, even though in object mode there is a distinct and important difference. The docs for Object-Mode also explicitly mention null as the *only* special cased value, making no mention of undefined.
LGTM |
Landed in 7fa4a96, thank you! |
Although I conceptually agree with this reasoning, is such a small change really worth merging and breaking back-compat? For a real use case example, I can no longer use gulp-watch as it depends on node-stream-array which relies on the old behavior of accepting I believe there should be more packages out there which rely on this behavior. Wouldn't it be more proper to add a legacy note to the docs and keep back-compat? //cc @indutny |
Why would An object stream should be able to carry any value that is serializable in JSON. Then it should allow IMO either you allow both as end of stream marker, or only |
Yep, it makes more sense actually. |
Accepting only |
Ok, just spent some time debugging some modules which broke because of this change. I also am not a fan. |
This also diverges from http://npm.im/readable-stream which does not have this patch -- @rvagg or @chrisdickinson any thoughts here? |
…7856 which is a breaking change
Need @chrisdickinson to weigh in on this but messing with the external API for streams is a huge risk at this stage and shouldn't be done lightly. There's a ton of code in npm that depend on minor details of the actual implementation and changes like this may be best seen as documentation problems rather than implementation problems. That said, if you want stability, use readable-stream@1.0.x, this is a 1.1.x detail for streams3. |
I am filled with unease by the thought that streams2 streams will still roam the earth despite streams3 being available. If this change is going to encourage that outcome, I'd almost prefer to back it out. On the other hand, we may be moving to a world where I think I have to come down on the side of backing this change out. If we're going to get to a world where @brycebaril I am curious, for future reference: how did the bug manifest? |
@chrisdickinson in http://npm.im/stream-spigot (a Readable stream helper) there is an Array helper that creates streams from arrays e.g. It is (roughly) implemented as The specific manifestation was in an objectMode stream causing an undefined property access error. Edit: tests smoked this out immediately when using versions with this patch. |
The Stream documentation for .push
explicitly states multiple times that null is a special cased value
that indicates the end of a stream. It is confusing and undocumented
that undefined also ends the stream, even though in object mode
there is a distinct and important difference.
The docs for Object-Mode also explicitly mention null as the only
special cased value, making no mention of undefined.