core-command icon indicating copy to clipboard operation
core-command copied to clipboard

Add Support for Retry in WP CLI Core Download Command

Open abhi3315 opened this issue 1 year ago • 2 comments

Description

This PR supports a retry mechanism in the WP CLI core download command. With the addition of --retry= and --retry-delay= flags, users can now specify the number of retry attempts and the delay between retries in case the download fails due to network issues or other transient errors.

Features Added:

  • The --retry=<retry> flag allows users to specify the number of retry attempts in case of download failure. The default value is set to 0.
  • The --retry-delay=<delay> flag allows users to specify the delay (in seconds) between retry attempts. The default delay is set to 5 seconds.

Usage Examples:

  • wp core download --retry=5 --retry-delay=10 - Downloads WordPress core with 5 retry attempts and a delay of 10 seconds between each attempt.
  • wp core download --retry=3 - Downloads WordPress core with 3 retry attempts using the default delay of 5 seconds between each attempt.

Issue: https://github.com/wp-cli/core-command/issues/155

abhi3315 avatar Apr 26 '24 10:04 abhi3315

We do have a recurring need for retries in several places, so I think it would make sense to add the capability for retries to Utils\http_request(). It has an $options argument that we can extend to support retry semantics.

The only thing to keep aware of is that it already contains a retry mechanism for retrying failed verified requests in an unverified way. The logic will probably end up looking more complex that it should because of that.

schlessera avatar Apr 26 '24 10:04 schlessera