Skip to content

Cancel HTTP/2 streams when requests are interrupted - #251

Closed
ekmartin wants to merge 1 commit into
socketry:mainfrom
ekmartin:ek-conductor/cancel-http2-streams
Closed

ekmartin wants to merge 1 commit into
socketry:mainfrom
ekmartin:ek-conductor/cancel-http2-streams

Conversation

@ekmartin

@ekmartin ekmartin commented Sep 27, 2026 •

Copy link
Copy Markdown

Interrupted HTTP/2 requests leave their streams open after the connection is released back to the pool. These abandoned streams consume the peer’s concurrent-stream capacity until the peer completes them, potentially causing healthy requests to fail with GoawayError: Exceeded maximum concurrent streams.

This change cancels an abandoned stream before the interruption propagates:

  • Use ensure and a completed flag around write_request and read_response, covering both timeouts and Async::Stop.
  • Send RST_STREAM with CANCEL only when the request is incomplete, the stream is active, and the connection is open.
  • Preserve the existing RefusedError checks for GOAWAY and closed connections.

A new loopback-server regression test times out /slow, verifies that the stream registry is empty, and successfully requests /fast on the same connection.

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.

1 participant