Skip to content

Commit 0c71119

Browse files
committed
resume() can throw
1 parent 37e2541 commit 0c71119

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

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

+13-7
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
238238
if (!flushed) {
239239
response.pause();
240240
res.once('drain', function () {
241-
response.resume();
241+
try { response.resume() }
242+
catch (er) { console.error("response.resume error: %s", er.message) }
242243
});
243244

244245
//
@@ -287,7 +288,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
287288
if (!flushed) {
288289
req.pause();
289290
reverseProxy.once('drain', function () {
290-
req.resume();
291+
try { req.resume() }
292+
catch (er) { console.error("req.resume error: %s", er.message) }
291293
});
292294

293295
//
@@ -370,7 +372,8 @@ HttpProxy.prototype._forwardRequest = function (req) {
370372
if (!flushed) {
371373
req.pause();
372374
forwardProxy.once('drain', function () {
373-
req.resume();
375+
try { req.resume() }
376+
catch (er) { console.error("req.resume error: %s", er.message) }
374377
});
375378

376379
//
@@ -470,7 +473,8 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
470473
if (!flushed) {
471474
proxySocket.pause();
472475
reverseProxy.incoming.socket.once('drain', function () {
473-
proxySocket.resume();
476+
try { proxySocket.resume() }
477+
catch (er) { console.error("proxySocket.resume error: %s", er.message) }
474478
});
475479

476480
//
@@ -501,7 +505,8 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
501505
if (!flushed) {
502506
reverseProxy.incoming.socket.pause();
503507
proxySocket.once('drain', function () {
504-
reverseProxy.incoming.socket.resume();
508+
try { reverseProxy.incoming.socket.resume() }
509+
catch (er) { console.error("reverseProxy.incoming.socket.resume error: %s", er.message) }
505510
});
506511

507512
//
@@ -619,7 +624,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
619624
// This will force us not to disconnect.
620625
//
621626
// In addition, it's important to note the closure scope here. Since
622-
// there is no mapping of the
627+
// there is no mapping of the socket to the request bound to it.
623628
//
624629
if (!agent._events || agent._events['upgrade'].length === 0) {
625630
agent.on('upgrade', function (_, remoteSocket, head) {
@@ -673,7 +678,8 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
673678
if (!flushed) {
674679
reverseProxy.socket.pause();
675680
socket.once('drain', function () {
676-
reverseProxy.socket.resume();
681+
try { reverseProxy.socket.resume() }
682+
catch (er) { console.error("reverseProxy.socket.resume error: %s", er.message) }
677683
});
678684

679685
//

0 commit comments

Comments
 (0)