Skip to content

Commit f638402

Browse files
indutnyrvagg
authored andcommitted
http: add comment about outputSize in res/server
PR-URL: #3128
1 parent 25e3b82 commit f638402

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/_http_outgoing.js

+7
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,16 @@ utcDate._onTimeout = function() {
4646
function 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;

lib/_http_server.js

+4
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
 (0)