Propagate error events throughout the chain #8

polotek opened this Issue Mar 4, 2012 · 0 comments


None yet
1 participant

polotek commented Mar 4, 2012

Once we have proc chain state, we can improve error handling. Essentially when an error occurs at a point in the chain, that error is propagated backwards in the chain until it hits an error handler, or it throws. Errors don't propagate forward, which allows you to set error handlers at various points in the chain and have things behave more or less as expected. Here's some more context from a discussion with @mikeal.

5:29 Marco Rogers
so, I'm assuming you think errors should propagate forward in the proc chain
like you should be able to set an error handler at the end
and catch everything

5:30 Mikeal Rogers

5:30 Marco Rogers
I can see how that's convenient, but it kinda sucks

5:30 Mikeal Rogers
that would make sense
is it?

5:30 Marco Rogers
how would you tell which thing failed?
and what if you wanted to handle parts of the chain separately?

5:31 Mikeal Rogers
p.createChild() -> self.on('error', child.emit.bind(child)
so, if you split the chain
both will get parent errors

5:32 Marco Rogers
when you say parent child, you mean earlier in the chain and later in the chain right?

5:32 Mikeal Rogers
but those child branches will only propagate themselves

5:33 Marco Rogers
you were confusing the shit out of me before with that

5:33 Mikeal Rogers

5:33 Marco Rogers
if you blindly forward errors then they will fire at every level

5:33 Mikeal Rogers
maybe you want a child error to emit on the parent

5:33 Marco Rogers
have errs propagate backwards

5:33 Mikeal Rogers
but only propagate until there is a handler
we had a proposal for this in streams that seemed smart

5:34 Marco Rogers
yep, I remember it
too bad nobody writes this shit down 
we need a node core stenographer

5:34 Mikeal Rogers

5:35 Marco Rogers
So the simple version was that when an error happened at any point in the pipe chain
it would break the pipe at that point
errors would flow backwards towards the readstream
but NOT forward
instead it would just call "end" on forward streams
so they know that the pipe is over, they don't need to know what happened

5:36 Mikeal Rogers
that's what i'm saying
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment