Skip to content

feat(client): retire pooled HTTP/2 connections on keep-alive reuse timeout - #319

Open
jiahaoliang wants to merge 3 commits into
hyperium:masterfrom
jiahaoliang:pr/h2-keepalive-reuse-timeout
Open

feat(client): retire pooled HTTP/2 connections on keep-alive reuse timeout#319
jiahaoliang wants to merge 3 commits into
hyperium:masterfrom
jiahaoliang:pr/h2-keepalive-reuse-timeout

Conversation

@jiahaoliang

@jiahaoliang jiahaoliang commented Sep 10, 2026

Copy link
Copy Markdown

fix hyperium/hyper#4186
related to: hyperium/hyper#4187

This PR implements the hyper-util portion of the shared reuse-timeout proposal, tracked in the Hyper issue. It lets the legacy Client stop reusing an unresponsive H2 connection while preserving the existing keep-alive hard timeout for its active streams. It depends on the companion Hyper API PR.

It adds http2_keep_alive_reuse_timeout(Option<Duration>), disabled by default. Each H2 handshake receives an observer holding only that connection's PoisonPill. Hyper's soft-timeout notification poisons the entry, and the existing pool availability checks prevent subsequent reuse.

The change preserves the current pool state machine, connection-establishment coordination, and retry policy. Existing requests and response bodies are not canceled by retirement. A late ACK can allow them to complete, but does not restore the entry to the pool. Already-checked-out requests can race with retirement; the feature does not proactively connect or replay requests.

Regression tests use real H2 over duplex IO with both directions paused, without EOF or reset. They cover:

  • Disabled behavior and ACK recovery before the soft deadline.
  • Replacement connections after retirement, including concurrent requests.
  • Completion of a pending response and an unfinished response body on the restored old connection.
  • Preservation of the original 60-second hard deadline in the test configuration.
  • Operation with adaptive window enabled.

Companion review CI passed the 5 new integration tests, 96 unit tests, 21 legacy-client tests, H1/H2 client feature checks, documentation generation, and formatting checks. The companion Hyper checkout was supplied only through the validation job’s temporary Cargo override.

The intended review order is Hyper API acceptance first, followed by this pool integration and the required released-dependency update.

…meout

Bind each handshake to its own poison observer and preserve in-flight streams.
Exercise replacement connections and recovery with controlled duplex IO.
Depends on the companion Hyper API; leave release selection to follow-up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow connection pools to stop reusing an HTTP/2 connection before its keep-alive timeout

1 participant