fix: retry on all TransportError subclasses (ReadError, WriteError, etc.)#334
Merged
fix: retry on all TransportError subclasses (ReadError, WriteError, etc.)#334
Conversation
Replace individual catches for ConnectError, RemoteProtocolError, and TimeoutException with a single catch for their parent class httpx.TransportError. This covers ReadError (TCP reset mid-response), WriteError, and all other transport-level failures that were previously falling through to PermanentError and not being retried. Discovered when api pods crashed mid-request and httpx raised ReadError with an empty message, which bypassed the existing retry logic. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
awalker4
approved these changes
Mar 25, 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.
Summary
exceptblocks forConnectError,RemoteProtocolError, andTimeoutExceptionwith a single catch for their parent classhttpx.TransportErrorReadError(TCP connection reset mid-response with empty message),WriteError, and all other transport-level failuresReadErrorfell through to the catch-allExceptionhandler and was wrapped asPermanentError, failing immediately without retryContext
Follow-up to #332. After deploying the
RemoteProtocolErrorfix, we observedhttpx.ReadError(empty message) failures when api pods crashed mid-response. The TCP connection was reset during the response read phase, which httpx classifies asReadErrorrather thanRemoteProtocolError.The httpx exception hierarchy:
Catching
TransportErroris the correct level — all transport errors are transient and should be retried whenretry_connection_errors=True.Test plan
retry_connection_errors=Trueretry_connection_errors=False🤖 Generated with Claude Code
Note
Medium Risk
Expands which network failures are treated as retryable, which can change error/latency behavior for callers and potentially mask persistent transport issues until backoff is exhausted.
Overview
Broadened retry handling for transport failures. The retry wrapper now catches
httpx.TransportErrorin both sync and async paths, so additional transport-level errors (e.g.ReadError,WriteError, and timeout subclasses) are retried whenretry_connection_errors=Trueinstead of being treated as permanent.Tests were updated to parameterize across multiple
TransportErrorsubclasses for both sync and async retry behavior, and the package version/release notes were bumped to0.42.12.Written by Cursor Bugbot for commit bdd403c. This will update automatically on new commits. Configure here.