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`);