Repository navigation
fix(retry): retry on connection reset by peer and unexpected EOF - #1567
Merged
TerryHowe merged 2 commits intoOct 13, 2026
Merged
Conversation
net/http never retries a request that failed on a fresh connection, so a single reset from a registry fails the whole operation although the retry policy is bounded and RoundTrip already rewinds request bodies. Treat syscall.ECONNRESET and io.ErrUnexpectedEOF as retryable in DefaultPredicate, next to the dial timeout. ECONNREFUSED, a bare io.EOF and unrelated errors are unchanged. Signed-off-by: Idan Rahamim <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
idan-rahamim-lendbuzz
requested review from
TerryHowe,
Wwwsylvia,
sabre1041 and
shizhMSFT
as code owners
October 13, 2026 10:07
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1567 +/- ##
==========================================
+ Coverage 92.08% 92.11% +0.03%
==========================================
Files 103 103
Lines 8437 8439 +2
==========================================
+ Hits 7769 7774 +5
+ Misses 657 654 -3
Partials 11 11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
TerryHowe
pushed a commit
that referenced
this pull request
Oct 13, 2026
…) (#1570) net/http never retries a request that failed on a fresh connection, so a single reset from a registry fails the whole operation although the retry policy is bounded and RoundTrip already rewinds request bodies. Treat syscall.ECONNRESET and io.ErrUnexpectedEOF as retryable in DefaultPredicate, next to the dial timeout. ECONNREFUSED, a bare io.EOF and unrelated errors are unchanged. Backport of #1567 to v2; tests adapted to this branch's test layout. (cherry picked from commit 055f8d1) Signed-off-by: Idan Rahamim <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
This was referenced Oct 13, 2026
Closed
Merged
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.
What this PR does / why we need it
retry.DefaultPredicatenow also retries a connection reset by peer (syscall.ECONNRESET) and an unexpected EOF (io.ErrUnexpectedEOF), next to the dial-timeout case. Go'snet/httpnever retries a request that failed on a fresh connection, so without this a single reset from a registry (seen with AWS ECR) fails the whole operation even though the request would succeed a moment later and the retry policy is bounded.Everything else is unchanged:
ECONNREFUSED, a bareio.EOFand unrelated errors are still not retried, andTransport.RoundTripkeeps refusing to retry a body it cannot rewind.Tests
policy_test.go: retry on a reset wrapped the waynet/httpreturns it (*url.Error→*net.OpError→*os.SyscallError), retry on a wrappedio.ErrUnexpectedEOF, no retry onECONNREFUSEDand on an unrelated error.client_test.go:Test_Client_RetryOnConnectionReset, anhttptestserver that hijacks the first connection, setsSetLinger(0)and closes it (RST), then serves 200;DefaultClient.Getgets the 200 on the second attempt. Skipped on Windows, where a reset surfaces asWSAECONNRESET, whicherrors.Is(…, syscall.ECONNRESET)does not match, so Windows keeps today's behaviour.gofmt,go vet,go test -race ./registry/remote/...pass; the new lines are covered.Notes for review
RoundTripis unchanged, so this does not add a new class of behaviour. If a method-based narrowing is preferred,RoundTriphas the request and it is a small follow-up.syscall.ECONNRESETcompiles on linux, darwin, windows, js/wasm and wasip1; it is undefined on plan9, where the module already does not build.oras.land/oras-go/v2, so a backport to thev2branch would be needed for it to benefit; I can open it once this is accepted.Which issue(s) this PR fixes
Fixes #1566