senchalabs/connect — Issue #486: Error: Can't set headers after they are sent.
Author: darkraven
Created: 2012-02-27 08:01:54+00:00
State: open

Shouldn't it be like this in next() at proto.js ? :
if ('test' != env) console.error(err.stack || err.toString());
if (res.headerSent) return req.socket.destroy();
res.setHeader('Content-Type', 'text/plain');
res.setHeader('Content-Length', Buffer.byteLength(msg));
if ('HEAD' == req.method) return res.end();
res.end(msg);
} else {
+ if(res.headerSent){
+ res.end();
+ return;
+ }
res.statusCode = 404;
res.setHeader('Content-Type', 'text/plain');
if ('HEAD' == req.method) return res.end();
res.end('Cannot ' + req.method + ' ' + utils.escape(req.originalUrl));
}