Created
February 21, 2013 19:27
-
-
Save ricardobeat/5007382 to your computer and use it in GitHub Desktop.
Silence socket hangup errors.
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
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
http://clock.co.uk/tech-blogs/preventing-http-raise-hangup-error-on-destroyed-socket-write-from-crashing-your-nodejs-server