Skip to content

Instantly share code, notes, and snippets.

@ricardobeat
Created February 21, 2013 19:27
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ricardobeat/5007382 to your computer and use it in GitHub Desktop.
Save ricardobeat/5007382 to your computer and use it in GitHub Desktop.
Silence socket hangup errors.
function hangups (req, res, next){
var reqd = domain.create()
reqd.add(req)
reqd.add(res)
reqd.on('error', function (error) {
if (error.code !== 'ECONNRESET') console.error(error, req.url)
reqd.dispose()
})
next()
}
app.use(hangups)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment