Add support for Node 0.8 domains - #81
#81Add support for Node 0.8 domains#81chrisdickinson wants to merge 3 commits into
Conversation
|
Cool, thanks for this pull request! I plan to move the tests to mocha anyway, so I should probably do that before merging the domains patch? |
|
No problem! Re: mocha, it looks like it may have the same issue as expresso -- again, it'll probably have to be fixed upstream. On the upside, at a glance it seems like the hack to make expresso work with domains will also work with mocha. One other thing to note: |
|
Okay, I feel better about this now: it should work on node <0.8.X (falling back to the old |
|
Some questions about the patch:
|
|
@ichernev To set domain properly through C++ would require looking at the global function createStatement() {
var stmt = new Statement
stmt.domain = process.domain
return stmt
}? If so, I'm +1 on that change. |
|
@chrisdickinson thanks for the explanation! So the EventEmitter constructor does that assignment. If so why not use it, inside |
|
That makes sense to me too |
|
FYI, node 0.9 has changed so that an uncaughtException is not emitted if there is an active domain |
|
this pull is stale. If anyone is keen on updating this work to support both node v0.8.x and v0.10.x and the new mocha tests then please open a new pull request. closing now without merging. |
This patch adds support for the domains module added in node 0.8.x.
Specifically, this patch changes the following:
Databasemethods attachprocess.domainto their returned statements asstatement.domainbefore returning them.TRY_CATCH_CALLmacro to useMakeCallback(a standard way to call back into node while respecting domain objects).EventEmitterconstructor function onDatabaseobjects upon instantiation since the constructor now has side effects based on the presence or absence of domains.Issues with Expresso
Expresso adds a
process.on('uncaughtException')listener that assumes test failure without checking that the error has been handled by a domain. Currently, there's a hacky way to disable that feature, but in the future that should be addressed upstream. For the time being, in the interest of not reporting false negatives, I've included a function wrapper that prevents expresso from freaking out.