Created
May 4, 2013 06:55
-
-
Save robertklep/5516529 to your computer and use it in GitHub Desktop.
Simple Express/Connect middleware that dumps a stack trace to console when response-headers are written. Useful to debug "Can't set headers after they are sent" issues.
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
// include this middleware before any middleware/routes that is suspected of triggering the error | |
app.use(function(req, res, next) { | |
res.on('header', function() { | |
console.trace('HEADERS GOING TO BE WRITTEN'); | |
}); | |
next(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment