From 882e11bae02c390706821cd66ffdbefd5b25fd16 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Thu, 6 May 2021 02:17:27 +0800 Subject: [PATCH] http2: fix hanging of `Http2ServerResponse`'s `end` method with no data Fixes: https://github.com/nodejs/node/issues/38258 --- lib/internal/http2/compat.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index a1ee6cdbbc7777..6f3874b3ecc599 100644 --- a/lib/internal/http2/compat.js +++ b/lib/internal/http2/compat.js @@ -755,7 +755,9 @@ class Http2ServerResponse extends Stream { } if (chunk !== null && chunk !== undefined) - this.write(chunk, encoding); + chunk = ''; + + this.write(chunk, encoding); state.headRequest = stream.headRequest; state.ending = true;