Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http2: delay closing stream #20997

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasnell I remember we discussed this, and you had a very good reason why this was there. Can you please weight in?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this extensively and I couldn't see a good reason. We (or nghttp2) don't let through any data from the other side as is anyway, so making the readable side open doesn't seem to make much sense... Would definitely love to know if there's something I missed though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am recalling correctly, this was there because of an earlier iteration. I don't think this is necessary now.


const headersList = mapToHeaders(headers);
if (!Array.isArray(headersList))
Expand Down