mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Since chunked writes are coalesced while the message is corked, write() decides backpressure from the byte length of the buffered chunks and sets kNeedDrain. When uncork() flushes them, net.Socket accounts string chunks in UTF-16 code units, so with multi-byte text it can stay below its own highWaterMark. It then never needs to drain and never emits 'drain'. If the flushed writes complete asynchronously, the check at the end of uncork() also runs while bytes are still pending, so the response stalls with writableNeedDrain === true and writableLength === 0. Re-check the drain condition once the flushed data has been written, unless the message or its socket has been destroyed in the meantime. Fixes: https://github.com/nodejs/node/issues/66781 Refs: https://github.com/nodejs/node/pull/64987 Assisted-by: AI coding agent Signed-off-by: junyup0503 <97156898+junyup0503@users.noreply.github.com> PR-URL: https://github.com/nodejs/node/pull/66782 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>