Skip to content

fix(updater): Windows 在线更新的五处可靠性修复 - #234

Open
wf0229 wants to merge 14 commits into
ECNU:mainfrom
wf0229:pr/updater-reliability
Open

wf0229 wants to merge 14 commits into
ECNU:mainfrom
wf0229:pr/updater-reliability

Conversation

@wf0229

@wf0229 wf0229 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

背景

Windows 在线更新在以下几种现场情况下会失败,或留下半新半旧的安装:

  • 安装目录的 ACL 无法写入(例如位于其他盘、属于其他用户的目录)。
  • 安全软件仍在扫描刚解压的文件,目录重命名被拒绝。
  • 更新程序轮询健康标记时,新版本替换该文件被短暂拒绝。
  • 上次更新中途被打断,留下的备份让此后每次重试都被拒绝。
  • 新版本启动时只是连不上发行配置服务,却触发回滚;回滚删除新版文件(如 vk_swiftshader.dll)时文件仍被占用,回滚失败。

改动

  1. ACL 写入被拒绝时不中止更新,交给健康握手判断新版本能否启动;失败照旧回滚。
  2. 安装器目录重命名最长等待 90 秒,失败提示说明安全软件与目录占用的处理办法。
  3. 替换健康标记文件被短暂拒绝时重试。
  4. 发现上次中断的备份时,把旧事务目录改名保留后继续,不再拒绝所有重试。
  5. 新版启动失败仅因发行配置无法通过网络获取(EDUWORK_BOOTSTRAP_REQUIRED 且为连接类错误)时,向更新程序确认健康,由新版本的失败页提供重试;证书错误和其他错误照旧回滚。回滚中的删除与还原每步最多重试 15 秒(退避 100 ms 起,上限 1 s)。

测试

  • 新增 TestRollbackWaitsForBrieflyLockedFile(Windows),以及 offlineConfiguration 的单元测试(只认网络类错误,排除证书错误与无可用配置)。
  • Windows 上的 updater / portable 测试由本 PR 触发的 Verify portable extractor 工作流运行。
  • node --test dsh-electron/tests/*.test.mjs:256 通过,0 失败。
  • macOS 上 go test ./internal/updater 的 TestGitHubElectronTransactionPreservesDataAndRollsBack、TestGoToElectronTransactionPreservesConfigDataAndRollsBackFailure 两项失败,在 main 上同样失败,与本 PR 无关。
  • source-receipt.json 已刷新(保留 createdAt),audit-eduwork-distribution --verify-receipt 无错误。

🤖 Generated with Claude Code

wf0229 and others added 8 commits October 26, 2026 05:15
…nied

The previous version already runs from the install folder; a denied WRITE_DAC
(e.g. D:\ folder owned by another account) does not prove the sandbox cannot
start. Record a trace and let the health handshake decide and roll back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
解压后 Defender、360、火绒等会逐个扫描新文件并占用目录,原来 5 秒的重试
窗口不够,用户在 D 盘安装时报 renameat … Access is denied。延长到 90 秒,
等待提示和失败提示说明安全软件、同步盘和换目录的处理办法。

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ndows

The Go updater reads health.ok every 200ms without FILE_SHARE_DELETE, so the
new version's atomic rename over it can fail with EPERM. The final 'ready'
write was uncaught, crashing the updated app and forcing a rollback.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ng retries

A transaction that was cut off (shutdown, closed helper, failed rollback)
left backup/ behind. Every later retry of that version then failed with
"previous update backup requires recovery before retry". With background
updates, the user would silently stay on the old version.

A retry is started by the program now installed, so that installation runs.
The updater now renames the old transaction to <version>.interrupted-<time>,
which keeps its files untouched, records previous-backup-retained in the
trace, and continues. If the new version fails health, rollback restores the
current files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Windows 在线更新后,新版本启动时连不上发行配置服务,会报启动失败并回滚;回滚删除
新版文件(如 vk_swiftshader.dll)时又因仍被占用而拒绝访问,留下半新半旧的安装。

- 新版启动失败只因发行配置因网络原因无法获取(超时、DNS、连接被拒绝或中断)时,
  仍向更新程序确认自检通过,由新版的失败页提供重试;证书错误和其他错误照旧回滚。
- 回滚中的删除与还原每步最多重试 15 秒,等残留子进程释放文件、安全软件扫描结束。

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
公版更新程序没有 update-trace 日志,保留备份的测试只检查备份确实保留。
安装器重命名最长等待 90 秒后,限时等待测试改用可调整的超时,避免测试本身跑满 90 秒。

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JJasonSun

Copy link
Copy Markdown
Contributor

#234 第 3 项与 #249 都修改 Windows 启动健康回执重试。建议更新到当前 main 时保留 #249 的重试与启动状态检查实现,删除重复部分;其余 Go 更新器改动再按 #234 的范围评审。

按维护者意见去掉本 PR 第 3 项:legacy-migration.mjs 与测试恢复为 main 的版本,
Windows 启动回执的重试与启动状态检查以 ECNU#249 为准。刷新源码收据(保留 createdAt)。

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@wf0229

wf0229 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

已按建议更新到当前 main,删除了第 3 项(健康标记替换重试),以 #249 的实现为准;剩下的 4 项(ACL、重命名等待、中断备份、配置服务离线不回滚)请按原范围评审。PR 描述里的「改动」一节已同步删掉第 3 条。

This branch has not been deployed

No deployments
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.

2 participants