Skip to content

Preserve completed HTTP/2 responses after repeated stream resets - #137255

Merged
krwq merged 3 commits into
mainfrom
krwq-http2-correctness-audit
Nov 25, 2026
Merged

krwq merged 3 commits into
mainfrom
krwq-http2-correctness-audit

Conversation

@krwq

@krwq krwq commented Nov 10, 2026

Copy link
Copy Markdown
Member

Note

This pull request description was generated with GitHub Copilot.

When a server sends a complete HTTP/2 response followed by RST_STREAM(NO_ERROR), we stop uploading the request body and keep the response, as required by RFC 9113 §8.1. However, if another reset arrives before the upload task observes cancellation, it can still discard the completed response and fail the request.

For applications sending large request bodies, this can make an early server response intermittently look like a network failure. Preserving the response lets callers handle the server's actual status and body instead of losing that information to a stream-reset exception.

Ignore subsequent reset notifications once the request body has been abandoned this way. The existing handling of the first reset and errors before the response completes stays unchanged.

Add a deterministic regression test using non-duplex StreamContent. It holds the upload open until a matching PING acknowledgment confirms that both resets have been processed, then checks that the original response is returned. The test covers STREAM_CLOSED with both completion options, plus CANCEL and INTERNAL_ERROR, and cleans up the connection and pending send on every exit path.

Validation

Validated on Windows x64 with locally built Debug libraries and Release CoreCLR:

  • All four new cases fail without the guard, with the corresponding second-reset error.
  • All four pass after rebuilding the product with the guard.
  • All 164 tests in SocketsHttpHandlerTest_Http2 pass with outer-loop coverage enabled, with no skips.
  • Product build passes with zero warnings or errors; git diff --check passes.

The full functional test suite and other platforms were not run. This demonstrates the repeated-reset race, not the reported production attribution or the separate GOAWAY + FIN scenario.

Fixes #135063

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @karelz, @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@ManickaP ManickaP left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This demonstrates the repeated-reset race, not the reported production attribution or the separate GOAWAY + FIN scenario.

Can we also add a test for the GO_AWAY?

The product code change looks good though.

Clarify test synchronization names and bound the blocked body read.

Co-authored-by: Copilot App <[email protected]>
Use scoped response and server-owned connection cleanup, release the upload gate on stream disposal, and bound the response wait.

Co-authored-by: Copilot App <[email protected]>
@krwq
krwq enabled auto-merge (squash) November 25, 2026 09:13
@krwq

krwq commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

CI Failures analysis

Job / failure Relation to PR Tracking Proposed action
MacCatalyst NativeAOT smoke: agent never connected Unrelated infrastructure dotnet/dnceng#6784, BA matched Reuse existing issue; no duplicate
Windows x86: WebSocket concurrent receives Unrelated to the new guard: extended CONNECT cannot set its flag #134815, BA matched Reuse existing issue; no duplicate
iOS NativeAOT: System.Runtime.Tests Unrelated environment failure during app build #127423, BA matched; disk exhaustion also fits #128758 Add occurrence to existing tracking if needed
iOS CoreCLR: System.Runtime.Tests Unrelated disk exhaustion during compilation #128758, BA matched Reuse existing issue; no duplicate
iOS CoreCLR: CoreCLR.R2R.Test Unmatched; cause not established No matching open dead-letter issue found Propose infrastructure investigation issue

@krwq

krwq commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

/ba-g The only unmatched failure is the dead-lettered iOS CoreCLR.R2R.Test, tracked in dotnet/dnceng#6790. Its work-item logs are missing, leaving no specific test error for Build Analysis to match. This startup smoke test does not exercise HTTP/2; all other failures are already matched to known issues.

@krwq
krwq merged commit 3ad46e5 into main Nov 25, 2026
67 of 69 checks passed
@krwq
krwq deleted the krwq-http2-correctness-audit branch November 25, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HTTP/2] HttpClient throws STREAM_CLOSED when server completes response + resets stream while client is still uploading a large request body

2 participants