Skip to content

Commit 37e2541

Browse files
committed
Emit drain if it doesn't happen on its own in 100ms
1 parent 6a7fd14 commit 37e2541

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

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

+48
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
240240
res.once('drain', function () {
241241
response.resume();
242242
});
243+
244+
//
245+
// Force the `drain` event in 100ms if it hasn't
246+
// happened on its own.
247+
//
248+
setTimeout(function () {
249+
res.emit('drain');
250+
}, 100);
243251
}
244252
}
245253
});
@@ -281,6 +289,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
281289
reverseProxy.once('drain', function () {
282290
req.resume();
283291
});
292+
293+
//
294+
// Force the `drain` event in 100ms if it hasn't
295+
// happened on its own.
296+
//
297+
setTimeout(function () {
298+
reverseProxy.emit('drain');
299+
}, 100);
284300
}
285301
}
286302
});
@@ -356,6 +372,14 @@ HttpProxy.prototype._forwardRequest = function (req) {
356372
forwardProxy.once('drain', function () {
357373
req.resume();
358374
});
375+
376+
//
377+
// Force the `drain` event in 100ms if it hasn't
378+
// happened on its own.
379+
//
380+
setTimeout(function () {
381+
forwardProxy.emit('drain');
382+
}, 100);
359383
}
360384
});
361385

@@ -448,6 +472,14 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
448472
reverseProxy.incoming.socket.once('drain', function () {
449473
proxySocket.resume();
450474
});
475+
476+
//
477+
// Force the `drain` event in 100ms if it hasn't
478+
// happened on its own.
479+
//
480+
setTimeout(function () {
481+
reverseProxy.incoming.socket.emit('drain');
482+
}, 100);
451483
}
452484
}
453485
catch (ex) {
@@ -471,6 +503,14 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
471503
proxySocket.once('drain', function () {
472504
reverseProxy.incoming.socket.resume();
473505
});
506+
507+
//
508+
// Force the `drain` event in 100ms if it hasn't
509+
// happened on its own.
510+
//
511+
setTimeout(function () {
512+
proxySocket.emit('drain');
513+
}, 100);
474514
}
475515
}
476516
catch (ex) {
@@ -635,6 +675,14 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
635675
socket.once('drain', function () {
636676
reverseProxy.socket.resume();
637677
});
678+
679+
//
680+
// Force the `drain` event in 100ms if it hasn't
681+
// happened on its own.
682+
//
683+
setTimeout(function () {
684+
socket.emit('drain');
685+
}, 100);
638686
}
639687
}
640688
catch (ex) {

0 commit comments

Comments
 (0)