Skip to content

Commit 3f263a8

Browse files
junyup0503ronagpar333k
committed
http: check message state before emitting drain
Rely on the message's own destroyed state instead of the socket's when re-checking the drain condition after the coalesced chunks are flushed. writableNeedDrain already excludes destroyed and finished messages. Refs: #66782 (comment) Co-authored-by: Robert Nagy <[email protected]> Co-authored-by: Park Jin Woong <[email protected]> Assisted-by: AI coding agent Signed-off-by: junyup0503 <[email protected]>
1 parent 96a0377 commit 3f263a8

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

‎lib/internal/http/outgoing.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,7 @@ OutgoingMessage.prototype.uncork = function uncork() {
380380
// chunks, but net.Socket counts string chunks in UTF-16 code units and
381381
// may stay below its own highWaterMark, so it never emits 'drain'.
382382
// Re-check once the flushed data has been written.
383-
const currentSocket = this[kSocket];
384-
if (!err && this.writableNeedDrain && currentSocket &&
385-
!currentSocket.destroyed && this.writableLength === 0) {
383+
if (!err && this.writableNeedDrain && !this.destroyed && this.writableLength === 0) {
386384
this[kNeedDrain] = false;
387385
this.emit('drain');
388386
}

0 commit comments

Comments
 (0)