From 82dfdf5c6612a95a83ca640b2abf7caf896afcf2 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Sat, 7 Sep 2024 09:16:36 -0700 Subject: [PATCH] comments --- src/js/node/http.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/js/node/http.ts b/src/js/node/http.ts index b9c7308b48..9d4a167701 100644 --- a/src/js/node/http.ts +++ b/src/js/node/http.ts @@ -1289,9 +1289,11 @@ ServerResponse.prototype._write = function (chunk, encoding, callback) { const headers = this[headersSymbol]; const hasContentLength = headers && getHeader(this[headersSymbol], "Content-Length"); if (hasContentLength) { + // wait for .end() return; } - + // We still wanna to wait for more writes if the user call 2 consecutives writes + // but if the user delay it too much we need to flush setTimeout(flushFirstWrite, 1, this); return; } @@ -1310,9 +1312,12 @@ ServerResponse.prototype._writev = function (chunks, callback) { const headers = this[headersSymbol]; const hasContentLength = headers && getHeader(this[headersSymbol], "Content-Length"); if (hasContentLength) { + // wait for .end() return; } + // We still wanna to wait for more writes if the user call 2 consecutives writes + // but if the user delay it too much we need to flush setTimeout(flushFirstWrite, 1, this); return; }