Skip to content

Instantly share code, notes, and snippets.

@regality
Created July 6, 2012 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save regality/3061748 to your computer and use it in GitHub Desktop.
Save regality/3061748 to your computer and use it in GitHub Desktop.
attempt at expressjs domains
app.use(function(req, res, next) {
var reqd = domain.create();
reqd.add(req);
reqd.add(res);
reqd.on('error', function(err) {
app.log.error(err + ' for url ' + req.url);
req.next(err);
});
res.on('finish', function() {
console.log('disposing');
reqd.dispose();
});
reqd.run(next);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment