On Thursday, October 4, 2012 7:55:50 AM UTC+2, Mikeal Rogers wrote: > > Domains work OOTB on all event emitters but have some complications with > callbacks and streams. > > Streams that are long running (like the redis client) don't get scoped to > the right domain since they are created early and never destroyed. > > Callbacks are not automatically bound to a domain, so any "normal" code in > them that throws will not be caught by the domain. > > At Summer Camp we discussed the best way to handle this problem. The > solution seemed to be that module authors, like the redis client, should > not scope their stream to a domain but instead must bind any callbacks > passed to them to process.domain if one exists. I would say the same should > go for libraries like async and any other library that "manages callbacks" > > This is a very long way of getting at what I think is the most important > part of flow control discussions after 0.8, that regardless of the > abstractions you use everyone needs to find a way to attach their errors to > the "active" domain if they want to be compatible with error handling in > node.js. Just like a promise library needs to expose something compatible > with the callback interface to get at APIs in core it'll need to check for > process.domain and bind it's success callbacks and error handling to it. >
I would love to play nicely with domains, but I'm not sure it's as straightforward as this. Promise libraries wrap all callbacks in a try/catch, storing any errors for potential future listeners, so there are no truly unhandled exceptions---simply ones that nobody has listened for, yet. So I'm not sure how you would surface those to a domain, or if it's even appropriate to do so. Guidance definitely appreciated. There's also the larger point, promises entirely aside, of whether domains are truly the future of error handling in Node. There has been no evangelism, or tutorials, and from what I've seen, very little adoption. So far they simply seem like the core team/illuminati's favorite error handling library, which just so happens to be distributed with node instead of through npm. I'd love it if everyone was agreed on a single solution, but the impression I got from summer camp was that the only people using domains are those who are (a) close to the core team, and (b) write applications, not just hack on node core itself. As I said, I want domains to succeed, even if only from the probably-in-your-eyes-misguided motivation that I like having standards handed down to me that we can all agree on, whether it be ES6 or domains. But I just don't see any effort or movement in that direction. -- 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
