http2: don't send trailers on a closed connection
There is a race condition between onStreamCloseResponse(), which removes the wantTrailers listener, and Http2Stream.close(), which will invalidate the connection. IE, sendTrailers can be called on a closed connection which would crash with a: Error [ERR_HTTP2_INVALID_STREAM]: The stream has been destroyed PR-URL: https://github.com/nodejs/node/pull/23146 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
b25e6abc68
commit
1bfd03565b
@ -330,7 +330,7 @@ function tryClose(fd) {
|
|||||||
function onStreamTrailers() {
|
function onStreamTrailers() {
|
||||||
const stream = this[kOwner];
|
const stream = this[kOwner];
|
||||||
stream[kState].trailersReady = true;
|
stream[kState].trailersReady = true;
|
||||||
if (stream.destroyed)
|
if (stream.destroyed || stream.closed)
|
||||||
return;
|
return;
|
||||||
if (!stream.emit('wantTrailers')) {
|
if (!stream.emit('wantTrailers')) {
|
||||||
// There are no listeners, send empty trailing HEADERS frame and close.
|
// There are no listeners, send empty trailing HEADERS frame and close.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user