From ec9fae96bccb65b1fa379d22af99598443b9ae60 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 6f6fcbd66038ac..2576600fd66e19 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -3110,7 +3110,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`);