Skip to content

[PR] fix(update): also run boot smoke for dsh desktop copy during in-place self-update (#2082) | fix(update): dsh 桌面副本原地自更新时也跑 boot smoke(#2082) - #6322

Closed
BBleae wants to merge 1 commit into
ranxianglei:masterfrom
mochi-fish:2026-11-12_update-boot-smoke-self-install
Closed

BBleae wants to merge 1 commit into
ranxianglei:masterfrom
mochi-fish:2026-11-12_update-boot-smoke-self-install

Conversation

@BBleae

@BBleae BBleae commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #6321

#2082 / #2091 的后续:boot smoke 这道门只接在一条通道上,dsh 桌面副本给自己更新时走的两条通道都没有启用它。

问题

#2091 给 installViaTarball 加了 opts.bootSmoke:新副本换上之后跑一次 node <installDir>/<main> --version,起不来就回滚。理由写在代码注释里——verifyEntries 只证明入口能解析,不证明能启动,而 dsh 桌面副本正是运行中的 dsh 在代理死掉后重新拉起的那一份。

但只有 refreshDshDesktopCopy 传了这个选项(由另一个 bili 进程刷新桌面副本的那条通道)。代理自己从桌面副本运行时:

结果:入口语法合法、一加载就抛错的包(顶层 throw、import 图断了、平铺的副本解析不到某个运行时依赖)在这两条通道上只过了 node --check,就被换进了桌面副本。这正是 #2091 要拦住的状态,而且在这种布局下更难恢复:坏掉的副本就是下次启动的那份,更新器本身也在它里面。

改动

源码只改了 src/update.ts:

  • 新增内部函数 isDshDesktopInstall(installDir):和 hostManagedInstall 开头一样的 realpath + isDshDesktopBiliCopy 判断。
  • checkForUpdate 和 forceInstallVersion 给 installViaTarball 传 { bootSmoke: isDshDesktopInstall(installDir) }。

bootSmoke 本身、回滚路径(restoreFromBackup,在删除备份之前)、失败后的退避以及日志,都保持 #2091 留下的样子。安装目录不是 dsh 桌面副本时这个选项为 false,行为不变。

测试

新增 tests/issue2082-self-update-boot-smoke.test.ts(5 个测试,照 issue2082-desktop-boot-smoke.test.ts 的写法:假包的入口只有一行 throw,boot smoke 起的是真的 node 子进程;registry 和 tarball 由进程内的 fetch 桩提供,不开 socket;DSH_HOME 和各缓存目录都指向这个测试文件自己的临时目录):

  1. 桌面副本上 checkForUpdate(自动)遇到加载即抛错的包:磁盘上保留旧版本,入口文件不变,不记 last-install,安装目录旁边不留任何东西。
  2. checkForUpdate(强制,即 bili update):同样回滚——磁盘上保留旧版本,入口文件不变,不记 last-install。
  3. forceInstallVersion 装进桌面副本:返回 ok: false,错误里带 boot smoke 和子进程的 stderr 那一行,磁盘上保留旧版本。
  4. 能正常加载的包在两条通道上都通过 smoke 并落地;last-install 的来源分别是 auto-update / advisory:<id>。
  5. 钉住范围:安装目录不是桌面副本时只跑解析检查(这只是钉住本 PR 的范围,不代表在那里解析检查就够了)。

改动前 1–3 失败(坏包被换了进去)、4–5 通过;改动后 5/5。

本地运行(Windows,Node 22,开着离线网络防护,用一次性的 home 目录):

  • tsc --noEmit --project tsconfig.json、check:unused-exports、check:test-import-graph:通过。
  • tests/update*.test.ts、tests/issue2082*.test.ts、tests/advisory*.test.ts、tests/issue3754-install-attribution.test.ts:200 / 200。
  • 主套件 tests/*.test.ts(1189 个文件,并发 4):11010 个测试,10925 通过 / 9 失败 / 9 取消 / 67 跳过。其中 8 个失败来自本地环境,和本改动无关:3 个是本地杀毒软件改写了回环 TLS 证书(graceful-close、issue3776-tls-mitm-diagnostics、responses-websocket 里的 WSS 用例),1 个是 log-retention 在非 UTC 时区下失败,3 个被离线防护挡住(main-path-transport-retry、mitm、upstream-proxy-routing,它们需要真实 DNS / 非回环地址),1 个是 issue3544-stale-proxy-rotation,因为 18787 端口上正跑着另一个 bili 实例。其余的(dsh-native 1 个失败 + 4 个取消、context-provenance-outbound 4 个取消、upstream-error-log 1 个超时)逐个文件重跑都通过。
  • 没跑:hermetic registry 套件(ACP_TEST_REGISTRY=1、tests/e2e/e2e-registry*),CI 上也还什么都没跑过;以 CI 的 test 各车道(以及 ci:full 下的 ci-registry)为准。

兼容性 / 风险

合并说明

改到了 src/update.ts(按 §7.4 属于 load-bearing),需要人工合并;并且按发版规则,更新器的改动要在一次 no-op 验证发版之后再发。在 CHANGELOG 的 [Unreleased] / Fixed 下加了一条。

Refs #2082, #2091

…elf in place (ranxianglei#2082)

The ranxianglei#2082 boot smoke (PR ranxianglei#2091) was wired into refreshDshDesktopCopy only,
the lane where another bili process refreshes the dsh desktop profile copy.
When the running proxy IS that copy, hostManagedInstall exempts the layout
(ranxianglei#1575) and the copy updates itself through the plain self-update lanes:
checkForUpdate (periodic check, `bili update`) and forceInstallVersion
(advisory force-install, web-panel install). Both called installViaTarball
without bootSmoke, so a tarball whose entry parses but throws at load was
swapped into the copy dsh respawns its plugin from.

Arm the smoke on both lanes when the install dir is the dsh desktop copy.
Other install layouts keep their current behaviour.
Copilot AI balanced review requested due to automatic review settings November 12, 2026 00:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request due to rate limiting. Please try again later. See Usage limits for GitHub Copilot for details.

@ranxianglei ranxianglei changed the title fix(update): dsh 桌面副本原地自更新时也跑 boot smoke(#2082) [PR] fix(update): also run boot smoke for dsh desktop copy during in-place self-update (#2082) | fix(update): dsh 桌面副本原地自更新时也跑 boot smoke(#2082) Nov 12, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

Landed via batch PR #6455 (merged) — closing as superseded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants