feat(ruby): implement HTTP status code-based retry with exponential backoff #11812
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.
Description
Refs: User-reported issue requesting exponential backoff retry logic for HTTP status codes (specifically 429 rate limit errors) to meet Square App Marketplace listing requirements.
Link to Devin run: https://app.devin.ai/sessions/5d7e9bfc387248cc89098c2b349cea6b
Requested by: @jsklan
This PR implements application-level retry logic with exponential backoff in the Ruby v2 SDK generator's RawClient, addressing a feature gap where the SDK previously only used Net::HTTP's network-level retries (which don't handle HTTP status codes like 429).
Update: Removed support for the non-standard X-RateLimit-Reset header as it has inconsistent unit implementations across different APIs, making it unreliable for retry timing.
Changes Made
RawClient.sendmethod that retries on specific HTTP status codesRetry-Afterheader (both seconds and HTTP date formats)Added support forRemoved - non-standard header with inconsistent implementationsX-RateLimit-Resetheader (Unix timestamp)[408, 429, 500, 502, 503, 504, 521, 522, 524](matches legacy SDK)INITIAL_RETRY_DELAY = 0.5s,MAX_RETRY_DELAY = 60s,JITTER_FACTOR = 0.2max_retries(set to 0) since we now handle retries at application levelversions.ymlwith changelog entry for v1.0.0-rc82 (updated to reflect X-RateLimit-Reset removal)Testing
pnpm run check)Human Review Checklist
Net::HTTP.max_retries- this means network-level failures (connection timeouts) won't be retried by Net::HTTP anymore, only by our application-level logic which checks HTTP status codesRetry-Afterheader parsing handles edge cases correctly