mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Emit drain if it doesn't happen on its own in 100ms
This commit is contained in:
parent
2b9e09b00a
commit
84be9f2c3a
@ -551,10 +551,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
|
||||
}
|
||||
}
|
||||
if (!flushed) {
|
||||
//console.error('backpressure 554');
|
||||
response.pause();
|
||||
res.once('drain', function () {
|
||||
response.resume();
|
||||
});
|
||||
setTimeout(function () {
|
||||
res.emit('drain');
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
|
||||
@ -587,10 +591,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
|
||||
if (!errState) {
|
||||
var flushed = reverseProxy.write(chunk);
|
||||
if (!flushed) {
|
||||
//console.error('backpressure 594');
|
||||
req.pause();
|
||||
reverseProxy.once('drain', function () {
|
||||
req.resume();
|
||||
});
|
||||
setTimeout(function () {
|
||||
reverseProxy.emit('drain');
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -661,10 +669,14 @@ HttpProxy.prototype._forwardRequest = function (req) {
|
||||
req.on('data', function (chunk) {
|
||||
var flushed = forwardProxy.write(chunk);
|
||||
if (!flushed) {
|
||||
//console.error('backpressure 672');
|
||||
req.pause();
|
||||
forwardProxy.once('drain', function () {
|
||||
req.resume();
|
||||
});
|
||||
setTimeout(function () {
|
||||
forwardProxy.emit('drain');
|
||||
}, 100);
|
||||
}
|
||||
})
|
||||
|
||||
@ -762,10 +774,14 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
|
||||
self.emit('websocket:outgoing', req, socket, head, data);
|
||||
var flushed = reverseProxy.incoming.socket.write(data);
|
||||
if (!flushed) {
|
||||
//console.error('backpressure 777');
|
||||
proxySocket.pause();
|
||||
reverseProxy.incoming.socket.once('drain', function () {
|
||||
proxySocket.resume();
|
||||
});
|
||||
setTimeout(function () {
|
||||
reverseProxy.incoming.socket.emit('drain');
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
@ -785,10 +801,14 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
|
||||
self.emit('websocket:incoming', reverseProxy, reverseProxy.incoming, head, data);
|
||||
var flushed = proxySocket.write(data);
|
||||
if (!flushed) {
|
||||
//console.error('backpressure 804');
|
||||
reverseProxy.incoming.socket.pause();
|
||||
proxySocket.once('drain', function () {
|
||||
reverseProxy.incoming.socket.resume();
|
||||
});
|
||||
setTimeout(function () {
|
||||
proxySocket.emit('drain');
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
@ -951,10 +971,14 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
|
||||
socket.write(sdata);
|
||||
var flushed = socket.write(data);
|
||||
if (!flushed) {
|
||||
//console.error('backpressure 974');
|
||||
reverseProxy.socket.pause();
|
||||
socket.once('drain', function () {
|
||||
reverseProxy.socket.resume();
|
||||
});
|
||||
setTimeout(function () {
|
||||
socket.emit('drain');
|
||||
}, 100);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user