Skip to content

Add curl retry with backoff and download concurrency limit - #115

Closed
angerman wants to merge 2 commits into
input-output-hk:mainfrom
angerman:fix/retry-backoff-download-concurrency
Closed

Add curl retry with backoff and download concurrency limit#115
angerman wants to merge 2 commits into
input-output-hk:mainfrom
angerman:fix/retry-backoff-download-concurrency

Conversation

@angerman

Copy link
Copy Markdown
Contributor

Summary

Fixes transient HTTP 502 failures when downloading source tarballs from GitHub under high parallelism (-j 0), as seen in cardano-haskell-packages CI run #21892846719 (PR #1248) which failed 4 times before succeeding on the 5th manual re-run.

Root cause

Three compounding factors in app/Foliage/FetchURL.hs:

  1. No curl-level retry — curl fails immediately on HTTP 502
  2. actionRetry 5 retries with zero delay — five instantaneous retries against an overloaded server all fail within milliseconds
  3. No download concurrency cap-j 0 means hundreds of concurrent curl processes hammer GitHub simultaneously

Changes

  • Add --retry 3 --retry-connrefused to curl invocations — curl retries transient HTTP errors (408, 429, 500, 502, 503, 504) with built-in exponential backoff (1s, 2s, 4s). The existing actionRetry 5 is kept as a second layer for non-HTTP failures (DNS, disk errors).
  • Cap concurrent downloads at 20 using Shake's Resource mechanism — prevents overwhelming GitHub when running with -j 0. Non-network tasks (patching, sdist creation, index building) still run at full parallelism.

Test plan

  • cabal build succeeds
  • All existing tests pass (cabal test)
  • Verify curl retries with backoff against a local 502 server
  • Verify at most 20 concurrent downloads with -j 0

Fix transient HTTP 502 failures when downloading source tarballs from
GitHub under high parallelism (-j 0).

Two changes:

1. Add --retry 3 --retry-connrefused to curl invocations. Curl retries
   transient HTTP errors (408, 429, 500, 502, 503, 504) with built-in
   exponential backoff (1s, 2s, 4s). The existing actionRetry 5 is kept
   as a second layer for non-HTTP failures.

2. Cap concurrent downloads at 20 using Shake's Resource mechanism.
   This prevents hundreds of simultaneous curl processes from
   overwhelming GitHub when running with -j 0. Non-network tasks
   (patching, sdist creation, index building) still run at full
   parallelism.
angerman added a commit to angerman/cardano-haskell-packages-1 that referenced this pull request Feb 11, 2026
Point foliage input at angerman/foliage#fix/retry-backoff-download-concurrency
(input-output-hk/foliage#115) to test the fix for transient HTTP 502
failures under high parallelism (-j 0).
- DeterminateSystems/nix-installer-action: v9 → v21
- DeterminateSystems/magic-nix-cache-action: v2 → v13
- cachix/cachix-action: v14 → v16

Fixes CI failures caused by TypeError: Invalid URL in the old
nix-installer-action when fetching from install.determinate.systems.
@angerman

Copy link
Copy Markdown
Contributor Author

Reopening as a non-fork PR from the same repo.

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.

1 participant