On Thursday, October 4, 2012 10:07:31 AM UTC+2, Mikeal Rogers wrote: > > I totally understand what you're saying but I think there are a few things > you're missing. > > The problem we had with errors in the node implementation of promises, > which was not great, was that errors were often unhandled because it was > extra typing to write a handler for them. This lead to "silent" failures, > which were terrible. This is why many better promise implementations throw > entirely unhandled errors. > > Q (and i'll assume deferred and make broad generalizations about promises > from here on out) has some amount of error propagation to make writing > handlers for errors easier, and so that they can live in less places, and Q > should not replace that with domains. BUT, if after propagation there is no > handler it should emit error on the domain (if it exists). >
Yes, this is something promise libraries still struggle with. The problem is, someone may perform an async operation, and not care about the result for some amount of time. The idea is you should be able to pass the rejected promise through multiple levels of your program before someone eventually decides they care and attaches a failure handler. There's no way to predict when or if that will happen though :(. The best we have so far is that you should always either (a) `return` the promise so it's now someone else's responsibility, or (b) signal that you're done, and not going to handle any errors, via extra typing (the `.end()` Marisz references). Sigh, the dark underbelly of promise-utopia comes to light... :P > Now, in places where Q takes a success callback and then wraps that in a > try/catch, it should also wrap code in the try statement in an enter/exit > for the current domain. A throw will still be caught by your try/catch > because domains don't do try/catch they wait for it to bubble up to > uncaughtException, but making sure your user's code runs in the same domain > they entered the promise with will mean that any event emitters or API > calls (in libraries by authors that are domain aware) can also get attached. > This makes a lot of sense, good call! -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
