HTTP/2: retry streams reset with REFUSED_STREAM or rejected by GOAWAY (RFC 9113 §8.7)#1298
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1298 +/- ##
==========================================
+ Coverage 86.88% 87.09% +0.20%
==========================================
Files 28 28
Lines 10898 11033 +135
==========================================
+ Hits 9469 9609 +140
+ Misses 1429 1424 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
quinnj
reviewed
Jun 10, 2026
…y GOAWAY are never retried Scripted-server tests (patterned on http2_client_tests.jl): the server refuses the first request - RST_STREAM(REFUSED_STREAM) or GOAWAY(last_stream_id=0) - then answers 200 to any later attempt, on the same or a new connection. With retry=true the client currently surfaces ProtocolError / H2GoAwayError after a single attempt; per RFC 9113 section 8.7 both cases are guaranteed unprocessed and safe to retry. Red until the retry fix lands. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…C 9113 8.7)
A stream reset with REFUSED_STREAM, or rejected by GOAWAY
(stream_id > last_stream_id), is guaranteed unprocessed by the server and is
safe to retry even for non-idempotent requests (RFC 9113 section 8.7). The
client previously surfaced these as ProtocolError("HTTP/2 stream reset by
peer") / H2GoAwayError after a single attempt, with the RST_STREAM error code
discarded.
- New H2StreamResetError carries the RFC 9113 section 7 error code; the
RSTStreamFrame handler stores it instead of a generic ProtocolError, and
showerror names the code (REFUSED_STREAM, CANCEL, ENHANCE_YOUR_CALM, ...).
- _retryable_request_error classifies REFUSED_STREAM resets and H2GoAwayError
as retryable; _h2_guaranteed_unprocessed lifts the idempotent-method gate
for them (the replayable-body gate still applies).
- The existing _drop_h2_conn! on error already makes the retry use a fresh
connection.
Greens the tests added in the previous commit.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The new test file was not listed in test/runtests.jl, so CI never executed it (codecov flagged the fix lines as uncovered). Also cover the codes without an unprocessed guarantee: a CANCEL reset surfaces H2StreamResetError on first occurrence without retry, and showerror names the RFC 9113 section 7 codes (REFUSED_STREAM, ENHANCE_YOUR_CALM, hex fallback for unknown codes). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
e81bd82 to
1f1016c
Compare
…scenarios codecov flagged _h2_guaranteed_unprocessed as uncovered: every existing test used GET, for which the idempotent-method gate short-circuits before the section 8.7 check is reached. Add POST scenarios: a refused POST and a POST rejected by GOAWAY are retried (in-memory body, replayable), while a cancelled POST surfaces without retry. The scripted server now skips request DATA frames. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
The remaining codecov gap was the §8.7 non-idempotent path (_h2_guaranteed_unprocessed), which GET requests short-circuit; 25171e6 covers it with POST scenarios (refused → retried, GOAWAY-rejected → retried, cancelled → surfaced without retry). |
Contributor
Author
|
Should be ready for merge |
quinnj
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1294.
H2StreamResetErrorcarries the RFC 9113 §7 error code (theRSTStreamFramehandler previously discarded it);showerrornames the code, e.g.HTTP/2 stream reset by peer: REFUSED_STREAM._retryable_request_errornow classifiesREFUSED_STREAMresets andH2GoAwayErroras retryable, and_h2_guaranteed_unprocessedlifts the idempotent-method gate for them per §8.7 (the replayable-body gate still applies)._drop_h2_conn!-on-error behaviour.RST_STREAM(REFUSED_STREAM)/GOAWAY(last_stream_id=0)) then answers 200 — red before the fix (single attempt surfaced as an error), green after (two attempts, fresh connection).Note: stream resets now raise
H2StreamResetError(anHTTPError) instead of a genericProtocolError— same pattern as the existingH2GoAwayError.