You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Closes#126. Refs #136. Supersedes #150 at the maintainer's invitation.
Adds a Kiota-owned retry handler to the default HTTP pipeline, with configurable retry policy, bounded exponential delays, and HTTP-date/delay-seconds Retry-After support.
Continues voidstack (@voidstackloop)'s implementation from #150, preserving the original commits and authorship. Discarded readable response bodies are drained and closed, including on read failure. Retry-count exhaustion raises a dedicated RetryExhaustedError containing a message and no retained response history; delay-budget exhaustion returns the final response to its caller. The handler preserves upload stream positions, avoids replaying non-seekable bodies, and bypasses parallel requests and response-streaming callbacks.
Validation on Windows for the latest change:
HTTP RSpec: 124 examples, 0 failures on MRI 3.4.9 and JRuby 10.1.2.0, each with Faraday 2.15.1 and the minimum supported Faraday 2.7.2.
RuboCop: 194 files, no offenses.
git diff --check: clean.
Regression coverage includes response cleanup without retained history, retry-count reporting, stream read failures, upload offsets, non-seekable bodies, and delay-budget boundaries.
Other OS/runtime combinations are left to upstream CI. CHANGELOG is managed by release-please and is not modified.
Latest review follow-up: drain response streams in 16 KiB chunks without retaining contents. Four regressions cover multiple chunks, nil/empty EOF, and a read failure after one successful chunk; the existing ensure still closes the stream. All 124 HTTP examples pass locally on MRI 3.4.9 and JRuby 10.1.2.0 with Faraday 2.15.1 and 2.7.2. Latest remote CI is reported separately.
- add a peer RetryHandlerOption class so retry behavior follows the
same request-context option pattern as the other Kiota handlers,
instead of unreachable constructor kwargs
- add YARD doc comments to the class and its public method
- narrow the Retry-After rescue to just the HTTP-date parse and
explain why a malformed header falls back to backoff instead of
raising
- add coverage for exponential backoff, retry exhaustion,
non-retryable status codes, and malformed Retry-After values,
plus validation tests for RetryHandlerOption's bounds
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Addresses the remaining review feedback on PR microsoft#150:
- scope the default RetryHandlerOption to the handler instance instead of
a class-level singleton, and accept one via the constructor
- move the retryable-status check onto RetryHandlerOption as a
configurable should_retry predicate instead of hardcoding it
- raise RetryExhaustedError (carrying every retryable response) once the
retry budget is exhausted, instead of silently returning the last
failed response
- add a retries_time_limit option bounding cumulative retry delay
- build a fresh env per retry instead of mutating the original request
headers/body in place
- read the retryable response body before each retry
Co-Authored-By: Claude Sonnet 5 <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Retries can replay different bytes from streams initially positioned past zero, leaving Content-Length inconsistent, and delay-budget checks can suppress the expected RetryExhaustedError after retries are exhausted.
Adds configurable retries to Kiota Ruby’s default HTTP pipeline, addressing HTTP-date Retry-After support in #126 and advancing the middleware work in #136.
Changes:
Add configurable retry policies, bounded backoff, and response history on exhaustion.
Handle response-stream cleanup and bypass retries for non-replayable requests.
Document configuration and add unit and regression coverage.
File
Description
README.md
Documents retry settings, exhaustion, and replay limits.
components/http/spec/retry_handler_spec.rb
Tests configuration, delays, policies, and pipeline integration.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The retry handler drains response streams with an unbounded read, causing potentially large transient allocations on every retry; it should read bounded chunks while preserving guaranteed closure.
Calling read without a length materializes the entire remaining response body before discarding it. For large streamed error responses, this defeats streaming and can cause a large transient allocation on every retry (a 1 MiB stream produces a single 1 MiB read here). Drain in bounded chunks while retaining the ensure that closes the stream.
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
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.
Closes #126. Refs #136. Supersedes #150 at the maintainer's invitation.
Adds a Kiota-owned retry handler to the default HTTP pipeline, with configurable retry policy, bounded exponential delays, and HTTP-date/delay-seconds Retry-After support.
Continues voidstack (@voidstackloop)'s implementation from #150, preserving the original commits and authorship. Discarded readable response bodies are drained and closed, including on read failure. Retry-count exhaustion raises a dedicated RetryExhaustedError containing a message and no retained response history; delay-budget exhaustion returns the final response to its caller. The handler preserves upload stream positions, avoids replaying non-seekable bodies, and bypasses parallel requests and response-streaming callbacks.
Validation on Windows for the latest change:
Other OS/runtime combinations are left to upstream CI. CHANGELOG is managed by release-please and is not modified.
Latest review follow-up: drain response streams in 16 KiB chunks without retaining contents. Four regressions cover multiple chunks, nil/empty EOF, and a read failure after one successful chunk; the existing ensure still closes the stream. All 124 HTTP examples pass locally on MRI 3.4.9 and JRuby 10.1.2.0 with Faraday 2.15.1 and 2.7.2. Latest remote CI is reported separately.