BigPizzaV3/CodexPlusPlus · error

下载安装包失败:

Error message

下载安装包失败:{error}

What it means

perform_update sends a GET request for the release asset via reqwest; if the request itself fails at the transport layer (DNS, connect, TLS, timeout), the error is logged to the diagnostic log as 'update.download.failed' and rethrown wrapped as 下载安装包失败:{error}. The original reqwest error text is embedded in the message.

Solutions

  1. Read the embedded reqwest error after the colon to identify the root cause (dns error, connection refused, timeout).
  2. Verify basic connectivity to the asset host (curl -I the asset_url) and any required proxy settings.
  3. Retry perform_update after confirming the network is stable — transient failures are common.
  4. Set HTTPS_PROXY/HTTP_PROXY env vars if updates must traverse a corporate proxy.
  5. If timeouts recur, check firewall rules for the download host or use a mirror URL for the asset.

Example fix

// before
let install = perform_update(&release, &dir).await?;
// after
match perform_update(&release, &dir).await {
    Ok(install) => ...,
    Err(e) if e.to_string().contains("下载安装包失败") => {
        log::warn!("update download failed, check network/proxy: {e}");
        // retry or prompt user to download manually
    }
    Err(e) => return Err(e),
}
Defensive patterns

Strategy: retry

Validate before calling

// pre-check reachability of the asset URL
let head = reqwest::Client::new().head(url).send().await?;
anyhow::ensure!(head.status().is_success(), "asset unreachable: {}", head.status());

Try / catch

match perform_update(&release, &dir).await {
    Err(e) if e.to_string().contains("下载安装包失败") => {
        // network-layer failure: backoff and retry
        tokio::time::sleep(Duration::from_secs(5)).await;
        perform_update(&release, &dir).await
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling perform_update when: the machine is offline or behind a captive portal; the asset URL host is unreachable or DNS fails; the 15s connect timeout or 600s download timeout elapses; a proxy/firewall blocks the connection; TLS handshake fails against a corporate MITM proxy.

Common situations: Updating from a restricted corporate network without proxy config; GitHub asset CDN (objects.githubusercontent.com) blocked in the region; transient network drop mid-update; VPN required but not connected.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/11fa83886b0370d4. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/update.rs:222

        .as_ref()
        .ok_or_else(|| anyhow::anyhow!("没有可下载的 Release asset"))?;
    let _ = crate::diagnostic_log::append_diagnostic_log(
        "update.perform.start",
        json!({
            "version": release.version,
            "assetName": release.asset_name,
            "assetUrl": url,
            "downloadTimeoutSeconds": UPDATE_DOWNLOAD_TIMEOUT.as_secs()
        }),
    );
    let response = match update_http_client()?.get(url).send().await {
        Ok(response) => response,
        Err(error) => {
            let _ = crate::diagnostic_log::append_diagnostic_log(
                "update.download.failed",
                json!({ "version": release.version, "assetName": release.asset_name, "error": error.to_string() }),
            );
            return Err(anyhow::anyhow!("下载安装包失败:{error}"));
        }
    };
    let response = match response.error_for_status() {
        Ok(response) => response,
        Err(error) => {
            let _ = crate::diagnostic_log::append_diagnostic_log(
                "update.download.bad_status",
                json!({ "version": release.version, "assetName": release.asset_name, "error": error.to_string() }),
            );
            return Err(anyhow::anyhow!("下载安装包失败:{error}"));
        }
    };
    let bytes = match response.bytes().await {
        Ok(bytes) => bytes,
        Err(error) => {
            let _ = crate::diagnostic_log::append_diagnostic_log(
                "update.download.body_failed",
                json!({ "version": release.version, "assetName": release.asset_name, "error": error.to_string() }),

View on GitHub (pinned to b1ed92e5e4)