readable-stream icon indicating copy to clipboard operation
readable-stream copied to clipboard

pipe broken

Open Raynos opened this issue 14 years ago • 3 comments

src.pipe(dest)

If dest emits close or error or finish the pipe is not cleaned up.

Meaning the src will continue writing to a broken stream

Raynos avatar Nov 21 '12 07:11 Raynos

I'm suffering this issue in my code. Say we've got

src1.pipe(transform1).pipe(transform2).pipe(dest1); 

Then transform2 does not get cleaned up (e.g., transform._flush does not get called) nor dest1 gets closed. You can checkout https://github.com/pablocaselas/stream-transform-bug for a working example with streams2. Tested also with readable-stream with same result. @pablocaselas created a similar issue to the node team: https://github.com/joyent/node/issues/6739

Posible fixes seem to be, IMHO:

  • stream.once "error", "close" and "finish" on Readable.pipe
  • At least stream.emit("end") in Writable as well as "finish" (in function finishMaybe(stream, state)).

manuelsantillan avatar Dec 19 '13 14:12 manuelsantillan

My fix is incorrect. My issue was related to not implementing flush correctly. Sorry for the noise.

manuelsantillan avatar Dec 20 '13 07:12 manuelsantillan

file report against joyent/node if this is still a problem.

rvagg avatar Jan 09 '14 02:01 rvagg