stream-utils/duplex-child-process — pull request #7 by jeromew (2014-07-13 18:07:17+00:00)
Title: Add `combined` stream tests / problem with stream-stream

I have been hunting a bug with duplex-child-process and combined streams with stream-stream (stream concatenation).

For stream concatenation, streams are pushed one after the other, so there is some kind of delaying taking place in the reading of the streams.

It appears that the "end" event is sent too early by duplex-child-process.

it is currently sent at the same time as the "close" event. But close is sent because the underlying resource (_process) is closed. According to me (and this is what I observe) this does not imply that the 'end' event should be sent because

This event fires when there will be no more data to read.

so when nothing is read, the duplex-child-process should not send it.

This PR show the problem with stream-stream. The test with combined-stream works because combined-stream "delays" all the events in a buffer. I have another downstream problem with combined-stream that I yet to track down in my project so I cannot use it as of now.

I will send shortly another PR that makes the test pass by :
- sending the 'end' event only when the _reader says that the end has been reached
- considering that the cleanup should be done upon "close" and that "end" has nothing to do with this

I hope you will agree with my analysis and that my PRs will be acceptable to you.