GeezerVison is showing github.com — http2: delay closing stream · nodejs/node@2a9912c
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/http2/core.js +5-2Lines changed: 5 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1906,7 +1906,10 @@ class Http2Stream extends Duplex { |
1906 | 1906 | !(state.flags & STREAM_FLAGS_HAS_TRAILERS) && |
1907 | 1907 | !state.didRead && |
1908 | 1908 | this.readableFlowing === null) { |
1909 | | - this.close(); |
| 1909 | + // By using setImmediate we allow pushStreams to make it through |
| 1910 | + // before the stream is officially closed. This prevents a bug |
| 1911 | + // in most browsers where those pushStreams would be rejected. |
| 1912 | + setImmediate(this.close.bind(this)); |
1910 | 1913 | } |
1911 | 1914 | } |
1912 | 1915 | } |
@@ -2178,7 +2181,7 @@ class ServerHttp2Stream extends Http2Stream { |
2178 | 2181 | let headRequest = false; |
2179 | 2182 | if (headers[HTTP2_HEADER_METHOD] === HTTP2_METHOD_HEAD) |
2180 | 2183 | headRequest = options.endStream = true; |
2181 | | - options.readable = !options.endStream; |
| 2184 | + options.readable = false; |
2182 | 2185 |
|
2183 | 2186 | const headersList = mapToHeaders(headers); |
2184 | 2187 | if (!Array.isArray(headersList)) |
|