0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

http2: delay closing stream

Delay automatically closing the stream with setImmediate in order
to allow any pushStreams to be sent first.

PR-URL: https://github.com/nodejs/node/pull/20997
Fixes: https://github.com/nodejs/node/issues/20992
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Anatoli Papirovski 2018-05-28 09:20:51 +02:00
parent 4b8ff3a424
commit 87cd389bbf
No known key found for this signature in database
GPG Key ID: 614E2E1ABEB4B2C0

View File

@ -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))