fix(runtime): 修掉 Windows 构建的 cfg(unix) 门控常量,解除 v1.3.5 发版阻塞 - #804
Merged
Conversation
v1.3.5 发布时 Windows x64 job 在 `Build Windows bundles` 失败:
error[E0425]: cannot find value `PID_START_TIME_TOLERANCE_MS` in this scope
--> crates\agent-gui\src-tauri\src\runtime\process.rs:246:56
#801 把这个常量定义为 `#[cfg(unix)]`(它的注释只讲了 `ps -o etime=` 的秒级精度),
但使用它的 `terminate_process_tree_by_pid_if_same` 是跨平台的:macOS / Linux 编译
都看不到问题,只有 Windows 目标才落到这条分支。
修复:常量改为所有平台可见,并补齐注释说明为何不能在 unix 下单独定义;windows 侧
`GetProcessTimes` 给的是精确创建时间,同一份 ±2s 宽容度只是稍宽,不会漏判 pid 复用。
验证:
- 把 `process.rs` 单独按 `--target x86_64-pc-windows-msvc` 做类型检查:修复前精确
复现同一处 E0425,修复后干净通过(本机缺 Windows SDK,整 crate 检查会死在
aws-lc-sys 的 C 构建)。
- `cargo check --lib`(host)无 warning;`cargo test --lib runtime::process` 3/3。
- 对 #801 全部改动做了 cfg 门控审计:新增引用到的 `spawn_and_reap` /
`spawn_child_reaper` / `terminate_process_tree_by_pid_if_same` /
`process_start_time_ms` 均无门控,此处是唯一的跨平台遗漏点。
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.
Closes #803
为什么会有这个 PR
打 tag v1.3.5 后
Desktop Release的 Windows x64 job 在Build Windows bundles失败:#801 新增的这个常量写成了
#[cfg(unix)],但使用它的terminate_process_tree_by_pid_if_same是跨平台函数。macOS / Linux 编译发现不了,CI 的
Tauri Rust Check也只跑 Linux —— 于是 PR 阶段全绿,代价是一次完整的失败发版。改动
只改一个文件、一行有效逻辑:常量去掉
#[cfg(unix)],并把注释补成说明为什么它必须在所有平台可见(unix 侧
ps -o etime=只有秒级精度才需要 ±2s 宽容度;windows 侧GetProcessTimes给的是精确创建时间,同一份宽容度只是稍宽,不会漏判 pid 复用)。验证
--target x86_64-pc-windows-msvc检查会死在aws-lc-sys的 C 构建;因此把process.rs单独放进一个最小 crate 做同目标检查 —— 修复前精确复现上面那处 E0425,修复后干净
通过(说明该文件在 Windows 目标下已无其它 cfg 遗漏)。
cargo check --manifest-path crates/agent-gui/src-tauri/Cargo.toml --lib:无 warning。cargo test --lib runtime::process:3/3 通过(含detached_child_is_reaped_instead_of_left_defunct)。spawn_and_reap/spawn_child_reaper/terminate_process_tree_by_pid_if_same/process_start_time_ms都无门控,fs.rs/git.rs/launcher.rs的新调用点也都在各自正确的平台分支里,此处是唯一的遗漏点。
后续
CI 缺 Windows Rust 检查这件事单列在 #803(workflow 文件改动需要
workflowscope,本机凭据没有,需由具备该 scope 的人加)。
发布动作
合并后工作区外的发版流程:把
v1.3.5指到这个提交并重新触发Desktop Release与
Gateway Docker(v1.3.5 尚未产出任何 GitHub Release,前者失败在 Windows 构建,后者已成功)。