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) {
|
if (!flushed) {
|
||||||
|
//console.error('backpressure 554');
|
||||||
response.pause();
|
response.pause();
|
||||||
res.once('drain', function () {
|
res.once('drain', function () {
|
||||||
response.resume();
|
response.resume();
|
||||||
});
|
});
|
||||||
|
setTimeout(function () {
|
||||||
|
res.emit('drain');
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -587,10 +591,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
|
|||||||
if (!errState) {
|
if (!errState) {
|
||||||
var flushed = reverseProxy.write(chunk);
|
var flushed = reverseProxy.write(chunk);
|
||||||
if (!flushed) {
|
if (!flushed) {
|
||||||
|
//console.error('backpressure 594');
|
||||||
req.pause();
|
req.pause();
|
||||||
reverseProxy.once('drain', function () {
|
reverseProxy.once('drain', function () {
|
||||||
req.resume();
|
req.resume();
|
||||||
});
|
});
|
||||||
|
setTimeout(function () {
|
||||||
|
reverseProxy.emit('drain');
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -661,10 +669,14 @@ HttpProxy.prototype._forwardRequest = function (req) {
|
|||||||
req.on('data', function (chunk) {
|
req.on('data', function (chunk) {
|
||||||
var flushed = forwardProxy.write(chunk);
|
var flushed = forwardProxy.write(chunk);
|
||||||
if (!flushed) {
|
if (!flushed) {
|
||||||
|
//console.error('backpressure 672');
|
||||||
req.pause();
|
req.pause();
|
||||||
forwardProxy.once('drain', function () {
|
forwardProxy.once('drain', function () {
|
||||||
req.resume();
|
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);
|
self.emit('websocket:outgoing', req, socket, head, data);
|
||||||
var flushed = reverseProxy.incoming.socket.write(data);
|
var flushed = reverseProxy.incoming.socket.write(data);
|
||||||
if (!flushed) {
|
if (!flushed) {
|
||||||
|
//console.error('backpressure 777');
|
||||||
proxySocket.pause();
|
proxySocket.pause();
|
||||||
reverseProxy.incoming.socket.once('drain', function () {
|
reverseProxy.incoming.socket.once('drain', function () {
|
||||||
proxySocket.resume();
|
proxySocket.resume();
|
||||||
});
|
});
|
||||||
|
setTimeout(function () {
|
||||||
|
reverseProxy.incoming.socket.emit('drain');
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
@ -785,10 +801,14 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
|
|||||||
self.emit('websocket:incoming', reverseProxy, reverseProxy.incoming, head, data);
|
self.emit('websocket:incoming', reverseProxy, reverseProxy.incoming, head, data);
|
||||||
var flushed = proxySocket.write(data);
|
var flushed = proxySocket.write(data);
|
||||||
if (!flushed) {
|
if (!flushed) {
|
||||||
|
//console.error('backpressure 804');
|
||||||
reverseProxy.incoming.socket.pause();
|
reverseProxy.incoming.socket.pause();
|
||||||
proxySocket.once('drain', function () {
|
proxySocket.once('drain', function () {
|
||||||
reverseProxy.incoming.socket.resume();
|
reverseProxy.incoming.socket.resume();
|
||||||
});
|
});
|
||||||
|
setTimeout(function () {
|
||||||
|
proxySocket.emit('drain');
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
@ -951,10 +971,14 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
|
|||||||
socket.write(sdata);
|
socket.write(sdata);
|
||||||
var flushed = socket.write(data);
|
var flushed = socket.write(data);
|
||||||
if (!flushed) {
|
if (!flushed) {
|
||||||
|
//console.error('backpressure 974');
|
||||||
reverseProxy.socket.pause();
|
reverseProxy.socket.pause();
|
||||||
socket.once('drain', function () {
|
socket.once('drain', function () {
|
||||||
reverseProxy.socket.resume();
|
reverseProxy.socket.resume();
|
||||||
});
|
});
|
||||||
|
setTimeout(function () {
|
||||||
|
socket.emit('drain');
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user