Created
March 11, 2013 05:37
-
-
Save synaptiko/5132097 to your computer and use it in GitHub Desktop.
Domains in node used for one request error handling from: http://www.youtube.com/watch?v=tgTniHwGPuM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http.createServer(function(req, res) { | |
var d = domain.create(); | |
d.add(req); | |
d.add(res); | |
d.on('error', function(er) { | |
console.error('Error', er, req.url); | |
d.dispose(); | |
}); | |
d.run(function() { | |
// Do dangerous stuff here | |
}); | |
}).listen(1337); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment