Skip to content

upgrade: ignore failed shared prefetches#22091

Merged
MikeMcQuaid merged 1 commit intomainfrom
homebrew-brew-upgrade-fails-to-retry-after-network
Apr 26, 2026
Merged

upgrade: ignore failed shared prefetches#22091
MikeMcQuaid merged 1 commit intomainfrom
homebrew-brew-upgrade-fails-to-retry-after-network

Conversation

@MikeMcQuaid
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid commented Apr 25, 2026

  • keep DownloadQueue#fetch output and failure handling unchanged while recording whether a shared fetch failed
  • stop brew upgrade reusing prefetched downloads after a failed shared fetch so later retries download again

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes. Non-maintainers may only have one AI-assisted/generated PR open at a time.

OpenAI Codex with several rounds of (mean) review and testing.


- keep `DownloadQueue#fetch` output and failure handling
  unchanged while recording whether a shared fetch failed
- stop `brew upgrade` reusing prefetched downloads after a
  failed shared fetch so later retries download again
- cover the mixed upgrade path and the `DownloadQueue`
  regression in specs
Copilot AI review requested due to automatic review settings April 25, 2026 18:56
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 fixes a brew upgrade edge case where a failed shared (combined) prefetch could cause subsequent upgrade logic to incorrectly treat downloads as reusable, preventing proper retry behavior. It does so by tracking whether a DownloadQueue#fetch run encountered any failures and disabling reuse of prefetched downloads when that happens.

Changes:

  • Add DownloadQueue#fetch_failed state to record whether fetch encountered rejected/failed downloads.
  • Update brew upgrade to avoid reusing prefetched downloads when the shared prefetch had any failures.
  • Add/extend unit coverage for both the new fetch_failed behavior and the upgrade flow decision.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
Library/Homebrew/download_queue.rb Tracks whether a fetch had any failures via @fetch_failed and exposes it via fetch_failed.
Library/Homebrew/cmd/upgrade.rb Disables use_prefetched / skip_prefetch when the shared download queue reports a failed fetch.
Library/Homebrew/test/download_queue_spec.rb Adds a spec ensuring parallel-mode rejected downloads set fetch_failed and mark Homebrew failed.
Library/Homebrew/test/cmd/upgrade_spec.rb Updates existing mocking for fetch_failed and adds coverage for not trusting failed shared prefetches.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Apr 26, 2026
Merged via the queue into main with commit 52b712d Apr 26, 2026
40 checks passed
@MikeMcQuaid MikeMcQuaid deleted the homebrew-brew-upgrade-fails-to-retry-after-network branch April 26, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants