File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -46,9 +46,16 @@ utcDate._onTimeout = function() {
4646function OutgoingMessage ( ) {
4747 Stream . call ( this ) ;
4848
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).
4951 this . output = [ ] ;
5052 this . outputEncodings = [ ] ;
5153 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.
5259 this . outputSize = 0 ;
5360
5461 this . writable = true ;
Original file line number Diff line number Diff line change @@ -265,6 +265,10 @@ function connectionListener(socket) {
265265 var outgoingData = 0 ;
266266
267267 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.
268272 outgoingData += delta ;
269273 if ( socket . _paused && outgoingData < socket . _writableState . highWaterMark )
270274 return socketOnDrain ( ) ;
You can’t perform that action at this time.
0 commit comments