From edfe86915941e465a06c1d0a3330ee32e5834aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Fri, 21 Dec 2012 20:56:01 +0100 Subject: [PATCH] [fix] Handle errors on request object Sometimes a request emits `error` event with a `Parse Error`. --- lib/node-http-proxy/http-proxy.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index ebfd56a6d..1348d3583 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -318,6 +318,11 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { socket.once('error', proxyError); }); + // + // Handle 'error' events from the `req` (e.g. `Parse Error`). + // + req.on('error', proxyError); + // // If `req` is aborted, we abort our `reverseProxy` request as well. // @@ -731,6 +736,11 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer) socket.once('error', proxyError); }); + // + // Handle 'error' events from the `req` (e.g. `Parse Error`). + // + req.on('error', proxyError); + try { // // Attempt to write the upgrade-head to the reverseProxy