Skip to content

Make H2 response header reads cancellation safe - #944

Draft
Pybsama wants to merge 1 commit into
cloudflare:mainfrom
Pybsama:codex/fix-h2-response-header-cancellation
Draft

Make H2 response header reads cancellation safe#944
Pybsama wants to merge 1 commit into
cloudflare:mainfrom
Pybsama:codex/fix-h2-response-header-cancellation

Conversation

@Pybsama

@Pybsama Pybsama commented Jul 30, 2026

Copy link
Copy Markdown

Closes #934.

What this changes

Http2Session::read_response_header() now drives the existing
poll_read_response_header() state machine through std::future::poll_fn.
That poll path restores the pending ResponseFuture to the session before
yielding, so an internal read timeout or external future cancellation cannot
drop the only continuation while leaving the session alive.

The existing timeout error and H2 response-error mappings are unchanged.

Tests

Added in-memory HTTP/2 regressions that:

  • time out through Http2Session::read_timeout, then resume and read a delayed
    200 response;
  • cancel the async read through an external Tokio timeout, then resume and read
    the same delayed response.

Local validation:

  • cargo test -p pingora-core --lib
  • cargo test -p pingora-core --lib --bins --tests --no-fail-fast
  • cargo test -p pingora-core --doc
  • cargo check --workspace
  • cargo fmt --all -- --check
  • cargo clippy -p pingora-core --lib -- --allow=unknown-lints --deny=warnings

The full pingora-core library result was 481 passed, 1 ignored, 0 failed.

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.

H2 response-header timeout can drop the only ResponseFuture and make the session panic on retry

1 participant