Skip to content

Cancel the handler context when a stream is reset - #5

Open
pagpeter wants to merge 1 commit into
masterfrom
http2-cancel-handler-ctx-on-reset
Open

pagpeter wants to merge 1 commit into
masterfrom
http2-cancel-handler-ctx-on-reset

Conversation

@pagpeter

Copy link
Copy Markdown
Owner

When the server resets a stream because of a stream error, the handler's request context stays live, so a handler waiting on r.Context().Done() never returns. Only a client RST_STREAM cancels it today.

Port of golang.org/x/net/http2 8aa6dbf4 (CL 585595, golang/go#67036): closeStream cancels the stream's context, in http2/server.go and h2_bundle.go.

TestH2ServerCancelsHandlerOnStreamError sends a second HEADERS frame on a stream to both servers through a small raw-frame client (h2_server_frames_test.go); each server's case fails without its one-line change. go test ./... passes.

🤖 Generated with Claude Code

When the server reset a stream because of a stream error, the handler's
request context stayed live, so a handler waiting on it never returned.
Only a client RST_STREAM canceled it.

Port golang.org/x/net/http2 8aa6dbf4 (CL 585595, golang/go#67036) to
http2 and to the bundled server in h2_bundle.go: closeStream cancels the
stream's context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pagpeter
pagpeter force-pushed the http2-cancel-handler-ctx-on-reset branch from b46f7e7 to 8f43832 Compare October 26, 2026 10:30
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