fix: retry preflight HEAD and prefer catalog size when downloading models (ATO-302)#182
Open
worthant wants to merge 2 commits into
Open
Conversation
…dels (ATO-302) The preflight HEAD request that resolves a model's file size ran exactly once, while the download stream itself retries up to 5 times. A single transient network blip (TLS handshake EOF, timeout) during HEAD therefore produced an immediate, unrecoverable 'Download failed'. - Skip the HEAD request entirely when the catalog already provides the file size (item.size), so it cannot fail the download at all. - When the size is unknown, retry the HEAD with the same policy as the stream (5 attempts, exponential backoff, cancel-aware), classifying transport errors and 408/429/5xx as retryable. - Make a preflight failure non-fatal: fall back to an unknown size and let the GET path (which has its own retries) surface the real error.
… ATO-302 - preflight_head_retries_dropped_connections: the server tears down the first two TCP connections before responding (the 'unexpected EOF during handshake' class of failure from the original report) and the preflight still resolves the size on the third attempt. - download_succeeds_when_preflight_head_always_fails: full _download_files_internal regression test — HEAD returns 500 on every attempt, yet the download completes via GET. Fails with 'Failed to get file size: HTTP status 500' on the pre-fix code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The preflight
HEADrequest that resolves a model's file size before download ran exactly once, while the download stream itself retries up to 5 times (MAX_STREAM_RETRIES, exponential backoff). A single transient network blip during HEAD — TLS handshake EOF, connection reset, timeout — produced an immediate, unrecoverable "Download failed", even though the actual download would have succeeded after a retry.Models are served from
huggingface.co, so this hit anyone with a flaky path to HF (DPI, VPN, HTTPS-inspecting antivirus, flapping ISP). Origin: Discord report (Windows 11, qwen35) withunexpected EOF during handshakein the logs.Fixes ATO-302.
Changes
src-tauri/src/core/downloads/helpers.rs:item.size) — no network round-trip at preflight, so nothing to fail.Tests
Six new tests in
src-tauri/src/core/downloads/tests.rs, all against real local HTTP/TCP servers:download_succeeds_when_preflight_head_always_fails— end-to-end regression test through_download_files_internal: HEAD returns 500 on every attempt, download still completes via GET. Verified to fail on pre-fixmainwith the exact bug (Failed to get file size: HTTP status 500).preflight_head_retries_dropped_connections— server tears down the first two TCP connections before responding (the handshake-EOF failure class from the report); size resolves on the third attempt.preflight_head_retries_transient_failures— two 500s, then success.preflight_uses_catalog_size_without_a_head_request— known catalog size ⇒ zero requests to the server.preflight_head_failure_is_not_fatal— permanent 500s ⇒ falls back to size 0 after 6 attempts, no error.preflight_head_does_not_retry_fatal_status— 404 is not retried.Full crate suite: 157 passed, 0 failed.