Translate HTTP protocol failures into Faraday connection errors - #61
Merged
Merged
Conversation
jakeonfire
approved these changes
Jul 30, 2026
jakeonfire
reviewed
Aug 7, 2026
| require "faraday/retry" | ||
|
|
||
| connection = Faraday.new(...) do |builder| | ||
| builder.request :retry, exceptions: [Faraday::ConnectionFailed] |
Contributor
There was a problem hiding this comment.
is this somewhat redundant with async-http's internal retries of socket failures? might this cause issues for PUT body streams that may have been drained? i have no qualms with the documentation, just trying to learn 🙂
samuel-williams-shopify
force-pushed
the
handle-remote-error
branch
from
September 18, 2026 10:54
e9f6005 to
eec8c95
Compare
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.
An HTTP/2 reset after response headers raises
Protocol::HTTP2::StreamErrorduring body consumption. It currently escapes the adapter without becomingFaraday::ConnectionFailed, so retry middleware configured for that exception misses the failure.Translate
Protocol::HTTP::ErrorintoFaraday::ConnectionFailed, preserving the original exception as its cause. This common base covers HTTP/1 and HTTP/2 errors, includingRemoteError,RefusedError, andStreamError, without enumerating subclasses in the adapter.The adapter adds no retries. The broader translation includes locally detected protocol errors and does not imply that retrying is safe or useful. The documentation demonstrates an explicit
faraday-retrypolicy for bodyless GET/HEAD requests and explains compounded attempts, request-body replayability, and partial streamed output.Regression tests retain the response-body failure path using
close_write(error)and enumerate concrete cases:RemoteError, HTTP/2 stream resets withINTERNAL_ERRORandCANCEL,RefusedError, HTTP/1ContentLengthError, HTTP/2GoawayError, and the common/HTTP1/HTTP2 base errors. Each verifies a successful middleware retry and preservation of the exact original cause. The existing async-http >= 0.99 requirement remains.Validation: 37 tests passed (192 assertions); RuboCop passed (21 files).
Fixes socketry/async-http#231.