diff --git a/lib/node-http-proxy.js b/lib/node-http-proxy.js index 55a4a35..027c8e7 100644 --- a/lib/node-http-proxy.js +++ b/lib/node-http-proxy.js @@ -125,16 +125,19 @@ exports.stack = function stack (middlewares, proxy) { handle = function (req, res) { var next = function (err) { if (err) { - console.error(err.stack); if (res._headerSent) { res.destroy(); - } else { + } + else { res.statusCode = 500; res.setHeader('Content-Type', 'text/plain'); res.end('Internal Server Error'); } + + console.error("error in middleware layer: %s", err.stack); return; } + child(req, res); }