diff --git a/doc/api/domain.markdown b/doc/api/domain.markdown index 4a0ee67dbb..b93c3fcd62 100644 --- a/doc/api/domain.markdown +++ b/doc/api/domain.markdown @@ -48,9 +48,11 @@ d.on('error', function(er) { // This is no better than process.on('uncaughtException')! console.log('error, but oh well', er.message); }); -require('http').createServer(function(req, res) { - handleRequest(req, res); -}).listen(PORT); +d.run(function() { + require('http').createServer(function(req, res) { + handleRequest(req, res); + }).listen(PORT); +}); ``` By using the context of a domain, and the resilience of separating our