Skip to content

Commit edfe869

Browse files
committed
[fix] Handle errors on request object
Sometimes a request emits `error` event with a `Parse Error`.
1 parent 6cd78f6 commit edfe869

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/node-http-proxy/http-proxy.js

+10
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,11 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
318318
socket.once('error', proxyError);
319319
});
320320

321+
//
322+
// Handle 'error' events from the `req` (e.g. `Parse Error`).
323+
//
324+
req.on('error', proxyError);
325+
321326
//
322327
// If `req` is aborted, we abort our `reverseProxy` request as well.
323328
//
@@ -731,6 +736,11 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
731736
socket.once('error', proxyError);
732737
});
733738

739+
//
740+
// Handle 'error' events from the `req` (e.g. `Parse Error`).
741+
//
742+
req.on('error', proxyError);
743+
734744
try {
735745
//
736746
// Attempt to write the upgrade-head to the reverseProxy

0 commit comments

Comments
 (0)