fix: 加固 Web UI 自更新重启路径#552
Open
hanzckernel wants to merge 1 commit intoEKKOLearnAI:mainfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这次改了什么
/api/update自更新不再直接执行npm/npm.cmd或全局hermes-web-uishim。process.execPath执行同一 Node 安装下的npm-cli.js,并用同一个 Node 启动全局包里的bin/hermes-web-ui.mjs重启。PATH npm。doUpdate()捕获更新请求 rejection,返回false并恢复updating状态,避免点击后 promise 直接冒泡导致按钮状态/反馈不可靠。根因证据
复现到一个关键路径问题:即使执行的是当前 Node 目录下的绝对
npm文件,它的 shebang 仍然可能是#!/usr/bin/env node,会重新从环境PATH解析node。本地验证:把假的
node放到PATH最前面后执行绝对 npm:改为
process.execPath npm-cli.js ...后,同样的污染PATH不会触发假 node,npm prefix -g正常返回当前 Node 前缀。相关问题 / 重复排查
PATH node。验证
npm test -- --run tests/server/update-controller.test.ts tests/client/app-store.test.ts— 通过,2 个测试文件 / 6 个测试npm run build— 通过npm test— 通过,63 个测试文件,396 passed / 2 skippedgit diff --check— 通过