From 487b7cbe0ce0bb0b8332a1d3e1f358ea65ef9d43 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Fri, 1 Mar 2024 15:20:14 +0100 Subject: [PATCH] http: clear chunked state before invoking callbacks Fixes a possible case where the chunked state is lost if updated through callback. --- lib/_http_outgoing.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index ddf742277a9..38facedce7b 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -336,6 +336,9 @@ OutgoingMessage.prototype.uncork = function() { const len = this[kChunkedLength]; const buf = this[kChunkedBuffer]; + this[kChunkedBuffer].length = 0; + this[kChunkedLength] = 0; + assert(this.chunkedEncoding); let callbacks; @@ -353,9 +356,6 @@ OutgoingMessage.prototype.uncork = function() { callback(err); } } : null); - - this[kChunkedBuffer].length = 0; - this[kChunkedLength] = 0; }; OutgoingMessage.prototype.setTimeout = function setTimeout(msecs, callback) {