developmentseed/node-sqlite3 — pull request #81 by chrisdickinson (2012-07-08 00:44:17+00:00)
Title: Add support for Node 0.8 domains

This patch adds support for the [domains module](http://nodejs.org/api/domain.html) added in node 0.8.x.

Specifically, this patch changes the following:

* All `Database` methods attach `process.domain` to their returned statements as `statement.domain` before returning them.

* Switched the `TRY_CATCH_CALL` macro to use `MakeCallback` \([a standard way to call back into node while respecting domain objects](https://github.com/joyent/node/blob/master/src/node.cc#L1003)\).

* Call the builtin `EventEmitter` constructor function on `Database` objects upon instantiation since the constructor [now has side effects based on the presence or absence of domains](https://github.com/joyent/node/blob/master/lib/events.js#L26).

* Add tests for database methods.

#### 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](https://github.com/chrisdickinson/node-sqlite3/blob/master/test/domain.test.js#L7), 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.