teambition / merge2

Merge multiple streams into one stream in sequence or parallel (~119M/month downloads).
MIT License
170 stars 14 forks source link

Error events are not merged / propagated #7

Closed theoy closed 8 years ago

theoy commented 8 years ago

Hi! I discovered merge2 off of the recommendation of another project... and I generally like the simplicity of merge2's stream composition API, but I got bit quite severely when I found that errors are not propagated.

Right now, I have to wrap all my usages of merge2, to listen to errors on source streams and then re-emit them on the merged stream as a workaround.

IMHO - there are probably a few classic error propagation strategies to offer when using merged streams:

  1. Eager errors - emit error event as soon as source stream emits one. This should probably be the default, and matches the asynchronous behaviour for Promise.all(...) and Promise.race(...) (the aggregate operation errors as soon as the first source operation errors).
  2. Deferred errors - bottle up errors until all streams have either ended or error'd. Option to aggregate errors / expose the full list of errors.
zensh commented 8 years ago

Just like as node.js's stream pipe don't make error propagated. Error propagated will cause other problem.

You can try pipe-errors, use it when you indeed need.