Commit 0c71119e authored by indexzero's avatar indexzero

resume() can throw

parent 37e25418
......@@ -238,7 +238,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
if (!flushed) {
response.pause();
res.once('drain', function () {
response.resume();
try { response.resume() }
catch (er) { console.error("response.resume error: %s", er.message) }
});
//
......@@ -287,7 +288,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
if (!flushed) {
req.pause();
reverseProxy.once('drain', function () {
req.resume();
try { req.resume() }
catch (er) { console.error("req.resume error: %s", er.message) }
});
//
......@@ -370,7 +372,8 @@ HttpProxy.prototype._forwardRequest = function (req) {
if (!flushed) {
req.pause();
forwardProxy.once('drain', function () {
req.resume();
try { req.resume() }
catch (er) { console.error("req.resume error: %s", er.message) }
});
//
......@@ -470,7 +473,8 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
if (!flushed) {
proxySocket.pause();
reverseProxy.incoming.socket.once('drain', function () {
proxySocket.resume();
try { proxySocket.resume() }
catch (er) { console.error("proxySocket.resume error: %s", er.message) }
});
//
......@@ -501,7 +505,8 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
if (!flushed) {
reverseProxy.incoming.socket.pause();
proxySocket.once('drain', function () {
reverseProxy.incoming.socket.resume();
try { reverseProxy.incoming.socket.resume() }
catch (er) { console.error("reverseProxy.incoming.socket.resume error: %s", er.message) }
});
//
......@@ -619,7 +624,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
// This will force us not to disconnect.
//
// In addition, it's important to note the closure scope here. Since
// there is no mapping of the
// there is no mapping of the socket to the request bound to it.
//
if (!agent._events || agent._events['upgrade'].length === 0) {
agent.on('upgrade', function (_, remoteSocket, head) {
......@@ -673,7 +678,8 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
if (!flushed) {
reverseProxy.socket.pause();
socket.once('drain', function () {
reverseProxy.socket.resume();
try { reverseProxy.socket.resume() }
catch (er) { console.error("reverseProxy.socket.resume error: %s", er.message) }
});
//
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment