diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 5a284a60771f26..4db1b9ea6e0720 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -1902,7 +1902,10 @@ class Http2Stream extends Duplex { !(state.flags & STREAM_FLAGS_HAS_TRAILERS) && !state.didRead && this._readableState.flowing === 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)); } } } @@ -2137,7 +2140,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))