Skip to content

Prebuilt installers: retry a download the server drops - #11816

Merged
danielhanchen merged 1 commit into
mainfrom
fix/prebuilt-retry-dropped-connections
Sep 24, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/prebuilt-retry-dropped-connections

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

A single dropped connection while downloading a prebuilt bundle skipped every retry. On #11808's Unsloth install + inference without Visual Studio leg (Windows, no build tools) the CPU bundle download was cut off once and the installer went straight to a source build, which that machine cannot do:

[llama-prebuilt] prebuilt fallback reason: candidate attempt failed before activation for
app-b11139-mix-a6922cc-windows-x64-cpu.zip: Remote end closed connection without response

HTTP_FETCH_ATTEMPTS is 4, but only errors is_retryable_url_error accepts are retried. urllib wraps just a failure to send the request in URLError; do_open calls h.getresponse() outside that wrapper, so a server that closes the connection before answering raises http.client.RemoteDisconnected (a ConnectionResetError) raw. A reset or short body during the read raises ConnectionResetError or http.client.IncompleteRead. None of these were retryable, so each one was fatal on the first attempt. The gap dates back to the classifier's introduction; this run is simply the first to hit it here.

Change

  • studio/prebuilt_core.py (llama.cpp and whisper.cpp): ConnectionError and http.client.IncompleteRead are retryable.
  • studio/install_node_prebuilt.py has its own copy of the classifier with the same gap; same change.

Both download loops already start each attempt from a fresh temp file or buffer, so a retry cannot splice two partial bodies together. Programming errors (ValueError, FileNotFoundError) are still not retried.

Test

New cases in tests/studio/install/test_prebuilt_core.py:

  • test_a_dropped_connection_is_retried: RemoteDisconnected, ConnectionResetError, ConnectionAbortedError and IncompleteRead, for both classifiers.
  • test_a_download_that_drops_once_is_retried_to_completion: a fake opener that drops once, before the response and mid-body, then serves the file; the download completes on the second request with the full body and no stray temp file.
  • test_a_programming_error_is_still_not_retried.

Against main's prebuilt_core.py and install_node_prebuilt.py the 10 dropped-connection cases fail; with this change all 12 pass. tests/studio/install, tests/test_setup_master_root.py and tests/test_installer_interactive_prompts.py: 9266 passed.

urllib wraps only a failure to send the request in URLError. A server that
closes the connection before answering raises http.client.RemoteDisconnected
out of getresponse(), and a reset or short body mid-download raises
ConnectionResetError or IncompleteRead; is_retryable_url_error treated all of
them as fatal, so one dropped connection skipped every remaining attempt.

On #11808's no-Visual-Studio Windows leg that sent a clean install to the
source build on the first attempt:

  candidate attempt failed before activation for
  app-b11139-mix-a6922cc-windows-x64-cpu.zip: Remote end closed connection
  without response

ConnectionError and IncompleteRead are now retryable in prebuilt_core (llama.cpp
and whisper.cpp) and in install_node_prebuilt, which had the same gap. Both
download loops already restart from a fresh temp file or buffer, so a retry
cannot splice two bodies together.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T15:43:04.733211Z cdf29fc Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: cdf29fc887

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 2c629b1 into main Sep 24, 2026
56 checks passed
@danielhanchen
danielhanchen deleted the fix/prebuilt-retry-dropped-connections branch September 24, 2026 15:44
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
urllib wraps only a failure to send the request in URLError. A server that
closes the connection before answering raises http.client.RemoteDisconnected
out of getresponse(), and a reset or short body mid-download raises
ConnectionResetError or IncompleteRead; is_retryable_url_error treated all of
them as fatal, so one dropped connection skipped every remaining attempt.

On unslothai#11808's no-Visual-Studio Windows leg that sent a clean install to the
source build on the first attempt:

  candidate attempt failed before activation for
  app-b11139-mix-a6922cc-windows-x64-cpu.zip: Remote end closed connection
  without response

ConnectionError and IncompleteRead are now retryable in prebuilt_core (llama.cpp
and whisper.cpp) and in install_node_prebuilt, which had the same gap. Both
download loops already restart from a fresh temp file or buffer, so a retry
cannot splice two bodies together.
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