fix(install): retry the HTTPS clone and degrade past repo-scoped 429s

GitHub throttles packfile generation for this repository with
repo-scoped HTTP 429s that are not client IP rate limits: an
anonymous clone of a small repo succeeds and the API quota is
untouched, but the single big pack behind --depth 1 dies
mid-transfer with 'RPC failed; HTTP 429 / expected packfile'. The
fresh-install clone path had no retry and no fallback, so a clean
machine exited 1 at the download stage and left a half-populated
install directory (same throttle as the update path in #89287).

Retry the HTTPS clone with linear backoff, removing the partial
clone between attempts; when every direct attempt fails, degrade
to a blobless partial clone and materialize the working tree with
a hard reset — many small packs instead of one big one, which is
what gets past the throttle. SSH-first ordering, the existing
installation update branch, and the commit-pin flow are unchanged.
This commit is contained in:
liuhao1024
2026-08-19 09:49:18 +08:00
committed by Teknium
parent f2f7a3bf15
commit 11afd07f16
2 changed files with 137 additions and 1 deletions
+43 -1
View File
@@ -1470,7 +1470,49 @@ EOF
else
rm -rf "$INSTALL_DIR" 2>/dev/null # Clean up partial SSH clone
log_info "SSH failed, trying HTTPS..."
if git clone --depth 1 --branch "$BRANCH" "$REPO_URL_HTTPS" "$INSTALL_DIR"; then
# GitHub throttles packfile generation for large repos (this one:
# ~9.6k files at HEAD plus thousands of auto-generated branches)
# with repo-scoped HTTP 429s that are NOT client IP rate limits —
# an anonymous clone of a small repo succeeds and the API quota
# is untouched, but the single big pack behind `--depth 1` dies
# mid-transfer with "RPC failed; HTTP 429 / expected 'packfile'"
# (#89624, same throttle as the update path in #89287). Retry
# with backoff, then degrade to a blobless partial clone + fetch
# (many small packs instead of one big one — what gets past the
# throttle). Fully materialize the tree afterwards so the rest of
# the installer sees the normal files.
local clone_ok=false
local attempt=0
local max_attempts=4
for attempt in 1 2 3 4; do
[ "$attempt" -gt 1 ] && log_info "Retrying HTTPS clone (attempt $attempt/$max_attempts)..."
if git clone --depth 1 --single-branch --branch "$BRANCH" \
"$REPO_URL_HTTPS" "$INSTALL_DIR"; then
clone_ok=true
break
fi
rm -rf "$INSTALL_DIR" 2>/dev/null # partial clone is unusable
[ "$attempt" -lt "$max_attempts" ] && sleep $((attempt * 5))
done
if [ "$clone_ok" != true ]; then
log_info "Direct clone throttled — trying blobless partial clone..."
if git clone --depth 1 --single-branch --filter=blob:none \
--branch "$BRANCH" "$REPO_URL_HTTPS" "$INSTALL_DIR"; then
# Materialize the working tree (fetches blobs in small
# packs; one retry helps when the fetch itself is
# throttled). The checkout git printed during the partial
# clone shows missing-content placeholders until this
# reset runs.
cd "$INSTALL_DIR" 2>/dev/null || true
git reset --hard HEAD >/dev/null 2>&1 \
|| git reset --hard HEAD >/dev/null 2>&1 \
|| true
clone_ok=true
else
rm -rf "$INSTALL_DIR" 2>/dev/null
fi
fi
if [ "$clone_ok" = true ]; then
log_success "Cloned via HTTPS"
else
log_error "Failed to clone repository"