Skip to content

fix(install): 下载失败时报出地址和原始错误,慢速下载不再被中断 - #259

Merged
sunerpy merged 1 commit into
mainfrom
fix/install-download-diagnostics
Nov 17, 2026
Merged

sunerpy merged 1 commit into
mainfrom
fix/install-download-diagnostics

Conversation

@sunerpy

@sunerpy sunerpy commented Nov 17, 2026

Copy link
Copy Markdown
Owner

问题

用户反馈(2026-11-17):Windows 11 上用 irm … | iex 安装 v0.3.1 时提示 release v0.3.1 has no SHA256SUMS (is 0.3.1 a Voltip release?),而发布中有这个文件。

  • install.ps1 用一个 catch 把 SHA256SUMS 的任何下载失败都报成文件缺失,原始错误(TLS、代理、超时)被丢掉。
  • install.sh 的 wget 用 -q,失败时什么都不显示;curl 先打印原始错误,紧接着又报出同样有误的结论。查询最新版本时 fetch | sed | head 的管道吞掉了下载失败,只报 could not find the latest release。

改动

  • scripts/install.ps1
    • 新增 Invoke-InstallRequest:失败时报出 URL、HTTP 状态和每一层内部异常的信息。HTTP 4xx(408、429 除外)立即停止,其他错误最多尝试 3 次,间隔 1 秒。
    • -TimeoutSec 30 只限制等待响应头的时间;PowerShell 7.4 起另加 -OperationTimeoutSeconds 30,数据停止 30 秒才结束下载,慢速下载不受影响。
    • 校验和不一致时报出已下载的字节数:Windows PowerShell 5.1 会把中途断开的下载当作已完成(见下文实测),只有校验能发现。
    • 报错时不再先用 Write-Host 打印一遍。
  • scripts/install.sh:curl 和 wget 各一个 download。curl 用 --connect-timeout 15 --speed-limit 1 --speed-time 30 --retry 2,不设总时长;wget 去掉 -q,用 --timeout=30 --tries=3。查询最新版本时先下载再解析。
  • .github/workflows/ci.yml:hooks-windows 在 Windows PowerShell 5.1 和 PowerShell 7 下各跑一遍 test_install_windows.ps1。它不需要工具链和安装包,放在这个 job 不用等交叉构建。
  • docs/site/guide/install.md、docs/site/zh/guide/install.md:各加一句,说明下载失败时检查什么。
  • docs/acceptance.md:一行命令安装这一行补上新行为、新测试和实测记录。

测试

先写测试,在原脚本上确认失败,再改脚本。

  • scripts/release/test_install_script.py:CurlDownloads / WgetDownloads 用真实的 curl 和 wget 访问本地假发布,只替换目标地址:403、404 不重试并报出地址和状态,503 重试,三次后停止。test_regression_a_slow_download_is_never_cut_off 检查每次下载都没有总时长上限、都有停滞检测(真实的慢速下载要十分钟,所以检查参数)。原脚本上这些用例全部失败,报错正是 has no SHA256SUMS。原有的 DebInstall 改为继承公共基类 FakeRelease,测试内容不变;简易的 fake curl 支持 -o -。
  • scripts/release/test_install_windows.ps1(新增,14 个用例):替换 web、进程和注册表相关的 cmdlet,按 irm | iex 的方式运行整个脚本。原脚本上 14 个全部失败。

本机:python3 -m unittest discover -s scripts/release -p 'test_*.py' 234 个通过;pwsh 7.6.3 下 14 个通过;shellcheck scripts/install.sh、scripts/check-acceptance-ledger.sh、.github/scripts/check-no-production-hosts.sh 通过。

Windows 真机(scripts/windows-remote.sh,Windows Server 2025,Windows PowerShell 5.1.26100 与 PowerShell 7.6.9):

  • test_install_windows.ps1 在两个版本下都通过。
  • 用脚本里真实的 Invoke-InstallRequest 访问本机故障服务器(时限调成 3 秒):连接被拒 3 次后报错,404 只试 1 次,503 后成功,响应头一直不到时 3 次后报错,50 KB 用 5 秒的慢速下载正常完成。7.6.9 下中途断开或连接重置后重下成功,数据停止 3 秒后结束。
  • 5.1 下中途断开的下载不报错,留下只有 1000 字节的文件。整个脚本对这样的假发布报 checksum mismatch for Voltip_0.3.1_x64-setup.exe (1000 bytes downloaded): nothing was installed;7.6.9 重下后校验通过。
  • 从 GitHub 实际下载最新版 0.3.1 的安装包(31,298,782 字节),两个版本都校验通过。安装和结束进程的命令已替换,没有安装,已在运行的 Voltip 未受影响。VOLTIP_VERSION=0.0.0 时报出 GitHub 的 404 和完整地址。

Linux:install.sh 对 GitHub 实测 VOLTIP_VERSION=0.0.0,curl 和 wget 都报出 404 和地址。

没有运行 make verify 里的 Rust 和 web 门禁:这个 PR 只改安装脚本、测试、CI 和文档,不涉及它们。

风险与回退

只影响一行命令安装。一行命令从 main 读取脚本,合并后即生效,不需要发版。回退:revert 这个提交。

用户反馈(2026-11-17):Win11 上安装 v0.3.1 时提示「has no SHA256SUMS」,
而发布中有这个文件。install.ps1 把任何下载失败都报成文件缺失并丢掉原始错误;
install.sh 的 wget 不显示错误,查询最新版本的管道也会吞掉下载失败。

- 失败时报出下载地址和原始错误。install.ps1 遇到 HTTP 4xx(408、429 除外)
  立即停止,其他错误最多尝试 3 次;install.sh 对超时和 HTTP 408、429、500、
  502、503、504 最多尝试 3 次
- 超时只针对停滞,慢速下载不会被中断:curl 用 --speed-limit/--speed-time,
  wget 用 --timeout;PowerShell 等待响应头最多 30 秒,7.4 起另加
  -OperationTimeoutSeconds 30
- install.ps1:校验和不一致时报出已下载的字节数(Windows PowerShell 5.1
  会把中途断开的下载当作已完成)
- 测试先写并在原脚本上失败:test_install_script.py 用真实 curl/wget 访问本地
  假发布;新增 test_install_windows.ps1,CI 在 hooks-windows 上用 5.1 和 7
  各跑一遍
- 安装文档两种语言各加一句;docs/acceptance.md 补上新测试和实测记录
@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #259      +/-   ##
==========================================
- Coverage   93.58%   93.57%   -0.01%     
==========================================
  Files         489      489              
  Lines       85908    85908              
  Branches     4909     4909              
==========================================
- Hits        80394    80391       -3     
- Misses       4845     4848       +3     
  Partials      669      669              
Flag Coverage Δ
rust 93.81% <ø> (-0.01%) ⬇️
web 92.39% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 12 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sunerpy
sunerpy merged commit 970beb9 into main Nov 17, 2026
17 checks passed
@sunerpy
sunerpy deleted the fix/install-download-diagnostics branch November 17, 2026 09:31
@github-actions github-actions Bot mentioned this pull request Nov 17, 2026
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