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:
parent
4b8ff3a424
commit
87cd389bbf
@ -1906,7 +1906,10 @@ class Http2Stream extends Duplex {
|
|||||||
!(state.flags & STREAM_FLAGS_HAS_TRAILERS) &&
|
!(state.flags & STREAM_FLAGS_HAS_TRAILERS) &&
|
||||||
!state.didRead &&
|
!state.didRead &&
|
||||||
this.readableFlowing === null) {
|
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;
|
let headRequest = false;
|
||||||
if (headers[HTTP2_HEADER_METHOD] === HTTP2_METHOD_HEAD)
|
if (headers[HTTP2_HEADER_METHOD] === HTTP2_METHOD_HEAD)
|
||||||
headRequest = options.endStream = true;
|
headRequest = options.endStream = true;
|
||||||
options.readable = !options.endStream;
|
options.readable = false;
|
||||||
|
|
||||||
const headersList = mapToHeaders(headers);
|
const headersList = mapToHeaders(headers);
|
||||||
if (!Array.isArray(headersList))
|
if (!Array.isArray(headersList))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user