--
--
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 nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/ZfaJPYyHKoA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.
I started working a project that demonstrate domains both on vanilla node and with express (it's based on the nodeconf session).
take a look and feel free to send pull requests.
from some reason the /database route does not get caught by the domain - https://github.com/oren/domains-examples/blob/master/express/server.js#L35
any idea what's missing there?
--
I had high hopes for the domains api, but it looks like this idea is either failed or has a very niche use, because I don't really remember any projects that use it.
I'll mention Promises, which give you async versions of try/catch/finally[1] and…
Personally, I'm excited about this low-level hook because it should make it possible to implement automatic long-stack traces without hacks (though this is probably something you would want to have only in debug mode due to the performance implications). It might even make it possible to avoid littering the code with "if (err) return cb(err)" (or d.intercept) at ever layer of asynchrony -- that would be quite nice.
--
FWIW co/koa still don't entirely solve the problem, there's really no way to completely solve it without coroutines with separate stacks,
I'll mention Promises, which give you async versions of try/catch/finally[1] and…Handling errors with promises is simple and clear (I find it one of the most pleasant parts of working with promises), but until the advent of bluebird, they incurred a pretty substantial performance penalty, if the main reason you were using promises was for error-handling. Having all those try clauses is expensive. And if you look at what bluebird has to do to get around that, it's kind of hairy and not all that different from what the domains system was doing under the hood.
Personally, I'm excited about this low-level hook because it should make it possible to implement automatic long-stack traces without hacks (though this is probably something you would want to have only in debug mode due to the performance implications). It might even make it possible to avoid littering the code with "if (err) return cb(err)" (or d.intercept) at ever layer of asynchrony -- that would be quite nice.You should take a look at https://github.com/joyent/node/pull/6011, which is the API to which Isaac is alluding. It's ready to be landed on node master pending review, and has the error-handling hooks you describe (in fact, in #6011, domains have been reimplemented in terms of the asyncListener API). I've been working with this API for a month or two now (I maintain the polyfill that brings its functionality back into 0.10 and 0.8: https://github.com/othiym23/async-listener), and while I think it offers a lot of improvements in terms of capturing information about errors, it's not a full replacement for traditional Node error-handling. In particular, you still need something like domains to keep the error-handling happening as close to the scope of where the errors are signaled as possible.And yes, the "Hello, World" of the asyncListener API is probably the long stacktrace module. Trevor Norris (the implementor of #6011) wrote one to debug the API, and a bunch of other people have done so as well. You're right -- generating all those stacktraces is expensive!
Personally, I'm excited about this low-level hook because it should make it possible to implement automatic long-stack traces without hacks (though this is probably something you would want to have only in debug mode due to the performance implications). It might even make it possible to avoid littering the code with "if (err) return cb(err)" (or d.intercept) at ever layer of asynchrony -- that would be quite nice.You should take a look at https://github.com/joyent/node/pull/6011, which is the API to which Isaac is alluding. It's ready to be landed on node master pending review, and has the error-handling hooks you describe (in fact, in #6011, domains have been reimplemented in terms of the asyncListener API). I've been working with this API for a month or two now (I maintain the polyfill that brings its functionality back into 0.10 and 0.8: https://github.com/othiym23/async-listener), and while I think it offers a lot of improvements in terms of capturing information about errors, it's not a full replacement for traditional Node error-handling. In particular, you still need something like domains to keep the error-handling happening as close to the scope of where the errors are signaled as possible.
Handling errors with promises is simple and clear (I find it one of the most pleasant parts of working with promises), but until the advent of bluebird, they incurred a pretty substantial performance penalty, if the main reason you were using promises was for error-handling. Having all those try clauses is expensive. And if you look at what bluebird has to do to get around that, it's kind of hairy and not all that different from what the domains system was doing under the hood.True. The end result however is an API that is simple and straightforward to use - arguably even easier than domains.