Node.js domains in Express app middleware -


i believe following code might useful handle exceptions occur requests:

var domain = require('domain');  app.use(function(req,res,next){      var d = domain.create();      d.on('error',function(err){       res.json({error: err.stack});     });      d.run(function(){        next();     });  }); 

however, read type of code can leak memory. not sure understand why. there way avoid leaking memory? perhaps should manually remove event handling , listeners domain after response stream closed? how allow domain object garbage collected?


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -