From 67b72b051537b79c4bf2ea28e9a5b60fa33b985f Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Fri, 6 Sep 2024 15:20:17 -0700 Subject: [PATCH] opsie --- src/js/node/http.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/js/node/http.ts b/src/js/node/http.ts index 5417070f6b..fead8aeee1 100644 --- a/src/js/node/http.ts +++ b/src/js/node/http.ts @@ -1254,6 +1254,8 @@ function flushFirstWrite(self) { self.headersSent = true; let firstWrite = self[firstWriteSymbol]; self[controllerSymbol] = undefined; + // at this point, the user did not call end and we have not flushed the first write + // we need to flush it now and behave like chunked encoding self._reply( new Response( new ReadableStream({ @@ -1282,10 +1284,9 @@ ServerResponse.prototype._write = function (chunk, encoding, callback) { this[firstWriteSymbol] = chunk; callback(); - if (this.header) - // we still wanna to flush if the user await some time before writing again - // keeping the first write is a good performance optimization - process.nextTick(flushFirstWrite, this); + // we still wanna to flush if the user await some time before writing again + // keeping the first write is a good performance optimization + process.nextTick(flushFirstWrite, this); return; }