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

Fix h2-over-h2 connection proxying #52368

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

pimterry
Copy link
Member

@pimterry pimterry commented Apr 4, 2024

This fixes #52344.

Previously, kSession was used on sockets to track the HTTP/2 session happening within that socket, and used on HTTP/2 streams to track the HTTP/2 session containing that stream (i.e. opposite directions in the connection 'stack').

This works fine most of the time, but when a HTTP/2 stream is used as the base for another HTTP/2 connection (using CONNECT proxying over an HTTP/2 stream) these two meanings conflict.

This didn't break until v20.12.0 because in that scenario a JS stream socket is used, and kSession was not passed through that layer until c50524a#diff-8dd7127678f00bf090a030256bad7ae645834f7100e54154b4fc81c8cbe9c3fc.

This fixes the issue by splitting into kBoundSession (the HTTP/2 session the socket is bound to) and kSession (the HTTP/2 session containing an HTTP/2 stream). I'm fairly sure I've updated all socket-specific use cases correctly to make that change, but it's worth carefully checking the uses of kSession to confirm. Notable parts include:

  • A slight simplification to callTimeout
  • Duplicating the kUpdateTimer call in setStreamTimeout

I think all these changes are exactly equivalent to the previous behaviour, except in the one edge case where something both contains and is contained by an HTTP/2 session.

I'm not sure the setStreamTimeout behaviour is actually correct (I'm not sure I fully understand the wider implications of that logic) but it is equivalent to the previous behaviour anyway so hopefully that's OK for now. Happy to change that to only do one or the other call if only one is actually correct.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/http2
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added http2 Issues or PRs related to the http2 subsystem. needs-ci PRs that need a full CI run. labels Apr 4, 2024
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 4, 2024
@richardlau richardlau added the lts-watch-v20.x PRs that may need to be released in v20.x label Apr 4, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 4, 2024
@nodejs-github-bot
Copy link
Collaborator

Copy link
Contributor

@ShogunPanda ShogunPanda left a comment

Choose a reason for hiding this comment

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

LGTM!

@debadree25 debadree25 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 5, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@mcollina mcollina added the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 8, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 8, 2024
@nodejs-github-bot nodejs-github-bot merged commit 3fc8d22 into nodejs:main Apr 8, 2024
69 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 3fc8d22

@pimterry pimterry deleted the h2-kSession-bound-error branch April 30, 2024 12:50
marco-ippolito pushed a commit that referenced this pull request May 2, 2024
PR-URL: #52368
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
marco-ippolito pushed a commit that referenced this pull request May 3, 2024
PR-URL: #52368
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
@richardlau richardlau added backported-to-v20.x PRs backported to the v20.x-staging branch. and removed lts-watch-v20.x PRs that may need to be released in v20.x labels May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. backported-to-v20.x PRs backported to the v20.x-staging branch. http2 Issues or PRs related to the http2 subsystem. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot CONNECT http2-over-http2 in Node 20.12.0
7 participants