Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 30, 2025

Implementation Complete: Add automatic retries to download paths

Properly rebased onto latest main branch using git rebase

Recent Updates

  • Fixed retry loop logic to execute exactly max_retries times (3 attempts) instead of 4
  • Integrated SSL insecure mode retry with transient error handling - now checks if errors after disabling cert validation are transient and allows retry loop to continue

Rebase Details

  • Base commit: 5aa34009 (Merge pull request Fix new PHPStan errors #6163 from wp-cli/fix/phpstan-errors)
  • Clean rebase with proper conflict resolution
  • Integrated latest SSL error handling improvements from main
  • All commits cleanly applied on top of main

Implementation Summary

Successfully implemented automatic retry mechanism for HTTP requests in WP-CLI with a hardcoded 3 retry threshold.

Key Features

  1. Hardcoded 3 retries - Simple, non-configurable retry mechanism (3 total attempts)
  2. Smart retry logic - Only retries on transient network errors (timeouts, connection issues)
  3. Exponential backoff - Uses 1s, 2s, 4s, 8s, 10s (max) delays between retries
  4. Clear debug logging - Shows retry 1/3, 2/3, 3/3 when --debug=http is enabled
  5. Backward compatible - No breaking changes, works transparently with existing code
  6. PHP 8.5+ compatible - Handles curl_close deprecation
  7. Properly integrated with main - Clean rebase onto latest main with improved SSL error handling
  8. SSL insecure mode integration - When SSL errors occur and cert validation is disabled, transient errors are properly handled by the retry mechanism

Transient Errors Handled

  • CURLE_OPERATION_TIMEDOUT (28) - Operation timeout
  • CURLE_COULDNT_RESOLVE_HOST (6) - Couldn't resolve host
  • CURLE_COULDNT_CONNECT (7) - Failed to connect
  • CURLE_PARTIAL_FILE (18) - Partial file transfer
  • CURLE_GOT_NOTHING (52) - Server returned nothing
  • CURLE_SEND_ERROR (55) - Send error
  • CURLE_RECV_ERROR (56) - Receive error

Files Changed

  • php/utils.php - Implemented retry logic and helper function with proper integration
  • tests/UtilsTest.php - Added unit test for transient error detection

Benefits

  • Improved reliability for downloads (themes, plugins, core, language files)
  • Better automated test stability
  • Reduced impact of transient network failures
Original prompt

This section details on the original issue you should resolve

<issue_title>Add automatic retries to download paths</issue_title>
<issue_description>For operations like downloading a theme or a language file, or latest Core code, we should have an automatic retry mechanism with a configurable threshold (defaulting to 3 as a good compromise).

This would not only make general scripting with WP-CLI more reliable but also drastically increase the reliability of our automated tests, which constantly fail due to random timeouts when doing downloads.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 63.93443% with 22 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
php/utils.php 63.93% 22 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI changed the title [WIP] Add automatic retries for downloading files Add automatic retry mechanism for HTTP requests with configurable threshold Oct 30, 2025
Copilot AI requested a review from swissspidy October 30, 2025 17:15
@swissspidy

This comment was marked as resolved.

This comment was marked as resolved.

Copilot AI changed the title Add automatic retry mechanism for HTTP requests with configurable threshold Add automatic retry mechanism for HTTP requests Oct 30, 2025
@swissspidy

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

Copilot stopped work on behalf of swissspidy due to an error October 31, 2025 00:42
@swissspidy

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

This comment was marked as resolved.

@swissspidy swissspidy force-pushed the copilot/add-automatic-retries-downloads branch from e9cc891 to ac7cbf1 Compare December 10, 2025 10:17
@swissspidy swissspidy requested a review from Copilot January 20, 2026 12:46
@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

This comment was marked as resolved.

swissspidy and others added 2 commits January 20, 2026 14:34
Co-authored-by: Copilot <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add automatic retries to download paths

2 participants