How to use Node.js 0.8.x domains with express?
How can I create Express/Connect middleware which wrap each request in its own domain? This set of slides on Speaker Deck gives a succinct overview: Domains in node 0.8 Express middleware code from the slides: var createDomain = require('domain').create; app.use(function(req, res, next) { var domain = createDomain(); domain.on('error', function(err) { // alternative: next(err) res.statusCode = 500; res.end(err.message + '\n'); domain.dispose(); }); domain.enter(); next(); }); UPDATE: The approach described below has been implemented in the connect-domain NodeJS module, which can be used in