{"record":{"id":"81e9439efd20663d","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-81e943","errorCode":null,"errorMessage":"读取安装包失败：{error}","messagePattern":"读取安装包失败：(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/update.rs","lineNumber":242,"sourceCode":"    };\n    let response = match response.error_for_status() {\n        Ok(response) => response,\n        Err(error) => {\n            let _ = crate::diagnostic_log::append_diagnostic_log(\n                \"update.download.bad_status\",\n                json!({ \"version\": release.version, \"assetName\": release.asset_name, \"error\": error.to_string() }),\n            );\n            return Err(anyhow::anyhow!(\"下载安装包失败：{error}\"));\n        }\n    };\n    let bytes = match response.bytes().await {\n        Ok(bytes) => bytes,\n        Err(error) => {\n            let _ = crate::diagnostic_log::append_diagnostic_log(\n                \"update.download.body_failed\",\n                json!({ \"version\": release.version, \"assetName\": release.asset_name, \"error\": error.to_string() }),\n            );\n            return Err(anyhow::anyhow!(\"读取安装包失败：{error}\"));\n        }\n    };\n    let _ = crate::diagnostic_log::append_diagnostic_log(\n        \"update.download.completed\",\n        json!({\n            \"version\": release.version,\n            \"assetName\": release.asset_name,\n            \"bytes\": bytes.len()\n        }),\n    );\n    let installer_path = match download_asset_to(release, &bytes, download_dir) {\n        Ok(path) => path,\n        Err(error) => {\n            let _ = crate::diagnostic_log::append_diagnostic_log(\n                \"update.write.failed\",\n                json!({\n                    \"version\": release.version,\n                    \"assetName\": release.asset_name,","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/update.rs#L224-L260","documentation":"Once a 2xx response is confirmed, perform_update buffers the full body with response.bytes().await. If reading the body fails mid-stream (connection reset, timeout while streaming, TLS truncation), the failure is logged as 'update.download.body_failed' and rethrown as 读取安装包失败：{error} with the reqwest error text embedded.","triggerScenarios":"Calling perform_update when the connection drops while streaming a large installer; the 600s UPDATE_DOWNLOAD_TIMEOUT elapses on a slow link; a proxy terminates the response early; the CDN aborts the transfer.","commonSituations":"Downloading a multi-hundred-MB installer over flaky Wi-Fi or mobile hotspot; corporate proxy with idle-connection kill; slow mirror truncating large files.","solutions":["Simply retry perform_update — body read failures are usually transient network interruptions.","Check link stability / switch networks before retrying large downloads.","If timeouts recur on slow links, download the installer manually via a browser or a resumable downloader (curl -C -).","Verify the downloaded file size afterwards if you implement your own retry, to guard against truncation.","Report persistent truncation against the specific mirror/proxy terminating the stream."],"exampleFix":"// before\nlet install = perform_update(&release, &dir).await?;\n// after\nlet install = match perform_update(&release, &dir).await {\n    Ok(i) => i,\n    Err(e) if e.to_string().contains(\"读取安装包失败\") => {\n        tokio::time::sleep(Duration::from_secs(5)).await;\n        perform_update(&release, &dir).await? // retry once on transient body failure\n    }\n    Err(e) => return Err(e),\n};","handlingStrategy":"retry","validationCode":"// check expected size if the manifest exposes one, or HEAD first\nlet expected = reqwest::Client::new().head(url).send().await?\n    .headers().get(reqwest::header::CONTENT_LENGTH)\n    .and_then(|v| v.to_str().ok()).and_then(|s| s.parse::<u64>().ok());","typeGuard":null,"tryCatchPattern":"match perform_update(&release, &dir).await {\n    Err(e) if e.to_string().contains(\"读取安装包失败\") => {\n        // truncated/mid-stream failure: short backoff, then retry\n        tokio::time::sleep(Duration::from_secs(3)).await;\n        perform_update(&release, &dir).await\n    }\n    other => other,\n}","preventionTips":["Prefer stable networks for large installer downloads; abort-and-retry is safe.","Note the 600s download timeout: on very slow links, download manually instead.","Avoid proxies that kill idle/long connections during large transfers.","After any manual download, verify the file size matches the asset's Content-Length."],"tags":["network","download","stream","timeout","update"],"backgroundTag":"network-request-failed","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}