Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed issue #364 'proxyError' event emitted twice

  • Loading branch information...
commit 43e5f3332081d3e9e61e3436eb99f7df8ca515c9 1 parent 26d3646
@erasmospunk authored
Showing with 25 additions and 7 deletions.
  1. +25 −7 lib/node-http-proxy/http-proxy.js
View
32 lib/node-http-proxy/http-proxy.js
@@ -312,9 +312,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
// Handle 'error' events from the `reverseProxy`.
//
reverseProxy.once('error', proxyError);
- reverseProxy.once('socket', function (socket) {
- socket.once('error', proxyError);
- });
+ //
+ // NOT needed as node.js re-emits the socket errors as ClientRequest 'error'
+ // Look for socketErrorListener references in
+ // https://github.com/joyent/node/blob/master/lib/http.js
+ //
+ // reverseProxy.once('socket', function (socket) {
+ // socket.once('error', proxyError);
+ // });
//
// Handle 'error' events from the `req` (e.g. `Parse Error`).
@@ -719,8 +724,13 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
return proxyError(ex);
}
+ //
+ // NOT needed as node.js re-emits the socket errors as ClientRequest 'error'
+ // Look for socketErrorListener references in
+ // https://github.com/joyent/node/blob/master/lib/http.js
+ //
// Catch socket errors
- socket.on('error', proxyError);
+ //socket.on('error', proxyError);
//
// Remove data listener now that the 'handshake' is complete
@@ -729,10 +739,18 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
});
});
+ //
+ // Handle 'error' events from the `reverseProxy`.
+ //
reverseProxy.on('error', proxyError);
- reverseProxy.once('socket', function (socket) {
- socket.once('error', proxyError);
- });
+ //
+ // NOT needed as node.js re-emits the socket errors as ClientRequest 'error'
+ // Look for socketErrorListener references in
+ // https://github.com/joyent/node/blob/master/lib/http.js
+ //
+ // reverseProxy.once('socket', function (socket) {
+ // socket.once('error', proxyError);
+ // });
//
// Handle 'error' events from the `req` (e.g. `Parse Error`).
Please sign in to comment.
Something went wrong with that request. Please try again.