Skip to content

补齐 CodexProcess handshake 失败/超时路径的 kill + wait 清理 #54

Description

@ghbvf

现状

全量 review 发现 codex app-server 冷启动失败路径缺少显式 reaping:

  • src-tauri/src/review/engines/codex/process.rs:66 spawn 出 Child。
  • src-tauri/src/review/engines/codex/process.rs:90 在构造 CodexProcess 前执行 handshake,失败会提前返回。
  • src-tauri/src/review/engines/codex/manager.rs:83 用 timeout(HANDSHAKE_TIMEOUT, CodexProcess::spawn(...)) 包住整个启动,超时会取消 spawn future。
  • 显式 start_kill() + wait() 只存在于已经构造成 CodexProcess 后的 kill_and_reap 路径。

也就是说 handshake error 或 timeout cancellation 发生在 CodexProcess 构造前时,只依赖 kill_on_drop(true),没有显式 wait。反复状态探测/启动失败可能留下 zombie。

三维根因

  • 代码:spawn 冷启动过程没有 child cleanup guard。
  • 架构:进程生命周期清理绑定在 CodexProcess self 上,但失败窗口发生在 self 构造前。
  • 历史:已有 stop/shutdown reaping,但未覆盖 handshake 前后的中间态。

影响

  • 反复握手失败或超时可能积累 zombie 进程。
  • 状态栏被动探测会触发启动路径,放大失败重试下的进程泄漏风险。

修复方向

  • 最小方案:在 CodexProcess::spawn 中引入 cleanup guard,handshake 失败时 start_kill 并 wait。
  • 彻底方案:把 handshake timeout 移入 CodexProcess::spawn 内部,让 spawn 自己拥有完整 child 生命周期。
  • 重构方案:抽象 process factory/lifecycle helper,CI-safe fake process 覆盖 handshake fail、timeout、stop during handshake。

Files

  • src-tauri/src/review/engines/codex/process.rs:66
  • src-tauri/src/review/engines/codex/process.rs:90
  • src-tauri/src/review/engines/codex/manager.rs:83

Source

Discovered via full-project review with 6 subagents on 2026-06-17.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions