Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit d0e61c900132595408359c22752c9be396dabc51 1 parent 06b3e32
@tj tj authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/http.js
View
5 lib/http.js
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.