feat(http): retry requests on transient error status codes#104
Merged
Conversation
Retry on 503, 521, 522, 524, 530 with delays of 100ms, 5s, 5s (max 3 retries). Adds executeWithRetry() helper used by doPost, doGet, and doDelete. Delays are a protected array for easy test overriding. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
🐕 Review complete — View session on Shuni Portal 🐾 |
…roperty lookup - Remove ZeroDelayAPI subclass (PSR2 requires one class per file) - Use ReflectionClass(API::class) to access private httpClient and protected retryDelaysUs on the parent class, matching the pattern used by APIExceptionMappingTest Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds automatic retry behavior for HTTP requests that fail with specific transient status codes, and extends the PHPUnit suite to cover the new behavior.
Changes:
- Introduces an
executeWithRetry()helper inAPIand routesdoGet,doPost, anddoDeletethrough it. - Adds a new PHPUnit test file validating retry behavior (success after retries, exhaustion, and non-retry cases).
- Updates
phpunit.xmlto include additional test files in the executed suite.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| src/SDK/API.php | Adds retry helper + wraps GET/POST/DELETE requests to retry on transient status codes. |
| src/tests/APIRetryTest.php | New tests verifying retry behavior and retry exhaustion behavior. |
| phpunit.xml | Ensures retry/mapping tests are actually run by the test suite. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove typed property declaration (array) and numeric separators from retryDelaysUs — requires PHP 7.4+ - Remove mixed return type from executeWithRetry — requires PHP 8.0+ - Replace nullsafe operator (?->) with explicit null check — requires PHP 8.0+ - Replace arrow functions (fn() =>) with traditional closures — requires PHP 7.4+ - Fix testDoesNotRetryOnNonRetryableStatusCodes: assert via (string)$e instead of getStatusCode() which does not exist on AuthException Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
slavikm
approved these changes
Mar 23, 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
https://github.com/descope/etc/issues/14039
executeWithRetry()helper used bydoPost,doGet, anddoDeleteprotectedproperty so tests can override without actual sleeps🤖 Generated with Claude Code