Make raise_error compose with retriable status retries - #848
Open
lineoffligbot wants to merge 1 commit into
Open
Make raise_error compose with retriable status retries#848lineoffligbot wants to merge 1 commit into
lineoffligbot wants to merge 1 commit into
Conversation
raise_error converts error responses into StatusError inside each attempt, blocking retry_statuses matching from seeing the response. This prevents retries and makes retry_statuses dead configuration when both features are enabled. Recover the response carried by StatusError in try_request, so retry_statuses matching, delay calculation, callbacks, and OutOfRetriesError all see it. Treat StatusError with matching status as retriable in retry_request?. Non-matching StatusErrors still raise immediately. Principle: raise-on-status should act only after retry-on-status is exhausted, but raise_error runs per-attempt inside the retry loop. Co-authored-by: Hakan Ensari <hakanensari@gmail.com>
hakanensari
force-pushed
the
fix/retriable-raise-error
branch
from
August 16, 2026 14:39
e86a77b to
671cdce
Compare
Contributor
Author
|
A note on the failing steep job: it is environment drift, not this patch. The Gemfile does not lock rbs ( |
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.
Problem
The
raise_errorfeature and theretriablefeature silently conflict. Enabling both makesretry_statusesdead configuration:raise_errorconverts an error response into aStatusErrorinside each attempt (Client#perform_oncewraps the response viafeature.wrap_response), soRetriable::Performercatches an exception instead of seeing a response.StatusErroris not inRETRIABLE_ERRORS, soretry_request?declines and the error is raised on attempt 1. Measured against a local always-503 server:retry_statuses: [503])OutOfRetriesErrorwith responseraise_errorStatusErrorStatusErrorinexceptions:OutOfRetriesErrorwith nil responseraise_errorwithignore:covering every retry statusOutOfRetriesErrorwith responseThe last row composes correctly but requires keeping two lists in sync by hand forever.
Fix
try_requestnow recovers the response aStatusErrorcarries:and
retry_request?treats a status-matchingStatusErroras retriable:Populating
researly repairs the whole downstream pipeline at once:retry_statusesmatching,Retry-Afterdelay calculation, theon_retrycallback, response flushing on exhaustion, andOutOfRetriesError#responseand#cause. AStatusErrorwhose status is not covered still raises immediately on attempt 1, preservingraise_errorsemantics. This also closes the nil-response hole in theexceptions:workaround (third row above).The underlying principle: raise-on-status should act only after retry-on-status is exhausted, but
raise_errorruns per attempt inside the retry loop, so the performer has to translate the exception back into its response.Notes on observable changes
on_retryandshould_retrycallbacks now receive the error response alongside theStatusError(previously the response argument was nil in that case).OutOfRetriesError#responseis populated when retries were driven by aStatusError, and#causeis theStatusError.Ten new tests cover the matrix rows, the preserved no-retry paths,
StatusErrorsubclasses, delay calculator and callback plumbing, and response flushing, all written to fail before the fix. RBS signature included. Mutant kills 100% of mutations on the diff.