Skip to content

fix(fetch): retry transient chunk and pack GET timeouts - #91

Merged
sanity merged 3 commits into
mainfrom
fix/36-chunk-get-retry
Nov 26, 2026
Merged

sanity merged 3 commits into
mainfrom
fix/36-chunk-get-retry

Conversation

@sanity

@sanity sanity commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Problem

A single pack or chunk GET that times out fails the whole clone or fetch (#36). On a slow or busy gateway, a large chunked clone such as the freenet-core mirror can fail on every attempt, because some chunk always hits the 180s timeout.

Approach

wsclient::retry_transient_get retries a GET only when it fails transiently: a timeout or gateway backpressure, using the existing ProbeOutcome/retry_disposition classification and retry_backoff. NotFound (authoritative, per the existing convention), hash mismatches and hard errors such as a closed connection are not retried.

  • Applies to the manifest and chunk GETs in chunked.rs and the SinglePack GET in download_bundle. rescue and the publish-verification GETs are unchanged.
  • 3 attempts by default. FREENET_GIT_CHUNK_RETRIES overrides this; an invalid value warns and falls back to the default, and 1 disables retrying.
  • The chunk pool's connection lock is taken per attempt, so a backoff sleep does not block sibling chunks.
  • A late reply from a timed-out attempt is safe. A reply for the same key can satisfy the retry and is still BLAKE3-verified; a reply for another key is skipped by the key matching in dispatch_get_response.
  • The final error keeps the original "timed out waiting for GET response" text in its cause chain.
  • The README troubleshooting section describes the retry and the env var.

Trade-off: when the gateway is completely unreachable, a clone takes up to about 3 times longer to fail (about 9 minutes per chunk in the worst case).

Testing

The tests were written first and failed on a single-attempt stub (4 retry tests plus the parser test), then passed with the fix:

  • retry_get_succeeds_after_one_timeout
  • retry_get_retries_host_backpressure
  • retry_get_gives_up_after_n_attempts_keeping_timeout_text
  • retry_get_does_not_retry_hash_mismatch_or_hard_errors
  • retry_get_does_not_retry_authoritative_not_found
  • retry_get_one_attempt_means_no_retry_and_unwrapped_error
  • retry_get_total_backoff_is_bounded
  • parse_fetch_get_attempts_handles_all_inputs

cargo test -p freenet-git, fmt and clippy (CI flags) are clean.

Review: Codex found nothing actionable. A skeptical lens found nothing blocking; its non-blocking points (wall time when the gateway is down, no test pinning that the lock is released before the sleep) are covered by the README note and the trade-off above.

Closes #36

[AI-assisted - Claude]

Stub retry_transient_get_with makes a single attempt; the new tests fail
until the retry loop is implemented in the next commit.

[AI-assisted - Claude]
Clone/fetch GETs of the manifest, each chunk and single packs now retry
on GET timeout or host backpressure (3 attempts by default, override with
FREENET_GIT_CHUNK_RETRIES; 1 disables). NotFound, hash mismatch and hard
errors are not retried. One stderr line per retry.

[AI-assisted - Claude]
@sanity
sanity merged commit 1905d2a into main Nov 26, 2026
6 checks passed
@sanity
sanity deleted the fix/36-chunk-get-retry branch November 26, 2026 04:08
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.

P2: per-chunk retry on transient timeout in fetch path

1 participant