diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 39d456fb75905f..7e2faa97bf02da 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -1906,7 +1906,10 @@ class Http2Stream extends Duplex { !(state.flags & STREAM_FLAGS_HAS_TRAILERS) && !state.didRead && this.readableFlowing === null) { - this.close(); + // By using setImmediate we allow pushStreams to make it through + // before the stream is officially closed. This prevents a bug + // in most browsers where those pushStreams would be rejected. + setImmediate(this.close.bind(this)); } } } @@ -2178,7 +2181,7 @@ class ServerHttp2Stream extends Http2Stream { let headRequest = false; if (headers[HTTP2_HEADER_METHOD] === HTTP2_METHOD_HEAD) headRequest = options.endStream = true; - options.readable = !options.endStream; + options.readable = false; const headersList = mapToHeaders(headers); if (!Array.isArray(headersList))