File tree 2 files changed +11
-0
lines changed
2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -46,9 +46,16 @@ utcDate._onTimeout = function() {
46
46
function OutgoingMessage ( ) {
47
47
Stream . call ( this ) ;
48
48
49
+ // Queue that holds all currently pending data, until the response will be
50
+ // assigned to the socket (until it will its turn in the HTTP pipeline).
49
51
this . output = [ ] ;
50
52
this . outputEncodings = [ ] ;
51
53
this . outputCallbacks = [ ] ;
54
+
55
+ // `outputSize` is an approximate measure of how much data is queued on this
56
+ // response. `_onPendingData` will be invoked to update similar global
57
+ // per-connection counter. That counter will be used to pause/unpause the
58
+ // TCP socket and HTTP Parser and thus handle the backpressure.
52
59
this . outputSize = 0 ;
53
60
54
61
this . writable = true ;
Original file line number Diff line number Diff line change @@ -265,6 +265,10 @@ function connectionListener(socket) {
265
265
var outgoingData = 0 ;
266
266
267
267
function updateOutgoingData ( delta ) {
268
+ // `outgoingData` is an approximate amount of bytes queued through all
269
+ // inactive responses. If more data than the high watermark is queued - we
270
+ // need to pause TCP socket/HTTP parser, and wait until the data will be
271
+ // sent to the client.
268
272
outgoingData += delta ;
269
273
if ( socket . _paused && outgoingData < socket . _writableState . highWaterMark )
270
274
return socketOnDrain ( ) ;
You can’t perform that action at this time.
0 commit comments