From 1f703e120403d41d4f274ad9d30a9512788e5edc Mon Sep 17 00:00:00 2001 From: Momtchil Momtchev Date: Sun, 18 Oct 2020 14:52:54 +0200 Subject: [PATCH] http2: fix reinjection check We reinject when the sockets has already waiting data, remarked by @mildsunrise Co-authored-by: Alba Mendez PR-URL: https://github.com/nodejs/node/pull/35678 Reviewed-By: Anna Henningsen Reviewed-By: Matteo Collina Reviewed-By: Rich Trott Reviewed-By: Alba Mendez Reviewed-By: Franziska Hinkelmann Reviewed-By: Ricky Zhou <0x19951125@gmail.com> --- lib/internal/http2/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index a938d543ed8fa2..7ae3a7565d97ee 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -3144,7 +3144,7 @@ function connect(authority, options, listener) { debug('Http2Session connect', options.createConnection); // Socket already has some buffered data - emulate receiving it // https://github.com/nodejs/node/issues/35475 - if (typeof options.createConnection === 'function') { + if (socket && socket.readableLength) { let buf; while ((buf = socket.read()) !== null) { debug(`Http2Session connect: injecting ${buf.length} already in buffer`);