Permalink
Browse files

Changed: dispatcher errors after header is sent destroy the sock

for example:

    .use(function(req, res){
      res.setHeader(Content-Type, text/plain);
      res.write(foo);
      res.write(foo);
      res.write(baz);
      res.end();
    })
  • Loading branch information...
1 parent 06b3e32 commit d0e61c900132595408359c22752c9be396dabc51 @tj tj committed Aug 27, 2011
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/http.js
View
@@ -149,7 +149,7 @@ Server.prototype.handle = function(req, res, out) {
// but wait! we have a parent
if (out) return out(err);
- // otherwise send a proper error message to the browser.
+ // error
if (err) {
var msg = 'production' == env
? 'Internal Server Error'
@@ -158,6 +158,9 @@ Server.prototype.handle = function(req, res, out) {
// output to stderr in a non-test env
if ('test' != env) console.error(err.stack || err.toString());
+ // unable to respond
+ if (res.headerSent) return res.socket.destroy();
+
res.statusCode = 500;
res.setHeader('Content-Type', 'text/plain');
res.end(msg);

0 comments on commit d0e61c9

Please sign in to comment.