-
Notifications
You must be signed in to change notification settings - Fork 1k
Add automatic retry mechanism for HTTP requests #6140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…eshold Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
…annotation Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements an automatic retry mechanism for HTTP requests in WP-CLI to improve reliability when downloading themes, plugins, core files, and language packs. The implementation adds exponential backoff retry logic that triggers on transient network failures (timeouts, connection issues) with a hardcoded limit of 3 retries.
Key changes:
- Added
is_transient_http_error()helper function to identify retryable network errors - Modified
http_request()to automatically retry on transient failures with exponential backoff (1s, 2s, 4s delays) - Added basic test coverage for transient error detection
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| php/utils.php | Implements retry loop with exponential backoff in http_request() and adds is_transient_http_error() helper to detect retryable curl errors |
| tests/UtilsTest.php | Adds test for is_transient_http_error() function with timeout error scenario and PHP 8.5+ curl_close handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
e9cc891 to
ac7cbf1
Compare
Implementation Complete: Add automatic retries to download paths
Properly rebased onto latest main branch using
git rebaseRebase Details
5aa34009(Merge pull request Fix new PHPStan errors #6163 from wp-cli/fix/phpstan-errors)Implementation Summary
Successfully implemented automatic retry mechanism for HTTP requests in WP-CLI with a hardcoded 3 retry threshold.
Key Features
--debug=httpis enabledTransient Errors Handled
Files Changed
php/utils.php- Implemented retry logic and helper function with proper integrationtests/UtilsTest.php- Added unit test for transient error detectionBenefits
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.