Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Jul 1, 2026. It is now read-only.

Add support for Node 0.8 domains - #81

#81
Closed
chrisdickinson wants to merge 3 commits into
TryGhost:masterTryGhost/node-sqlite3:masterfrom
chrisdickinson:masterchrisdickinson/node-sqlite3:masterCopy head branch name to clipboard
Closed

Add support for Node 0.8 domains#81
chrisdickinson wants to merge 3 commits into
TryGhost:masterTryGhost/node-sqlite3:masterfrom
chrisdickinson:masterchrisdickinson/node-sqlite3:masterCopy head branch name to clipboard

Conversation

@chrisdickinson

Copy link
Copy Markdown

This patch adds support for the domains module added in node 0.8.x.

Specifically, this patch changes the following:

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.

@kkaefer

kkaefer commented Jul 8, 2012

Copy link
Copy Markdown
Contributor

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?

@chrisdickinson

Copy link
Copy Markdown
Author

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: MakeCallback (in C++-land) was introduced in 0.8 -- so it won't compile against <0.8 with this patch. I'm looking into wrapping the TRY_CATCH_CALL in a #if statement so we can use the old definition on pre-0.8.X code -- I just need to figure out what I should be comparing against (if node supplies a WITH_DOMAINS directive or if we should supply our own.) The JS code should be unaffected -- the statement.domain = process.domain; line should effectively be a no-op on pre-0.8.X code. I'll update the PR when I figure out a way forward.

@chrisdickinson

Copy link
Copy Markdown
Author

Okay, I feel better about this now: it should work on node <0.8.X (falling back to the old TRY_CATCH_CALL), as well as supporting domains where available. If domains aren't available, the domain tests are skipped.

@ichernev

ichernev commented Oct 8, 2012

Copy link
Copy Markdown

Some questions about the patch:

  • why do you set statement.domain to the current domain? I couldn't find a "best practice" or sth about this. If you save the current domain to .domain on Statementobjects, why not also set them on Database objects?
  • it seems you set the current domain to each statement object after creation -- can't you put that logic in C++'s Statement construction code? If not -- why now wrap Statement construction in a js function, that would set .domain properly.

@chrisdickinson

Copy link
Copy Markdown
Author

@ichernev .domain gets automatically set on descendants of EventEmitter -- as you can see, I'm calling EventEmitter against the Database object here.

To set domain properly through C++ would require looking at the global process object in C++ (which seemed hairy to me). If I follow your alternate suggestion, would it look something like:

function createStatement() {
  var stmt = new Statement
  stmt.domain = process.domain
  return stmt
}

? If so, I'm +1 on that change.

@ichernev

ichernev commented Oct 8, 2012

Copy link
Copy Markdown

@chrisdickinson thanks for the explanation! So the EventEmitter constructor does that assignment. If so why not use it, inside createStatement than an explicit stmt.domain = process.domain? It'll be clearer that way IMHO.

@aredridel

Copy link
Copy Markdown

That makes sense to me too

@cxreg

cxreg commented Feb 14, 2013

Copy link
Copy Markdown

FYI, node 0.9 has changed so that an uncaughtException is not emitted if there is an active domain

@springmeyer

Copy link
Copy Markdown
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.