Skip to content

fix: ShellProcessRunner timeout throws timedOut instead of nonZeroExit - #1

Merged
linletian merged 3 commits into
mainfrom
fix/opencode-error-logging
Jun 16, 2026
Merged

fix: ShellProcessRunner timeout throws timedOut instead of nonZeroExit#1
linletian merged 3 commits into
mainfrom
fix/opencode-error-logging

Conversation

@linletian

Copy link
Copy Markdown
Owner

问题

ShellProcessRunner 超时时会 terminate 进程,进程被 SIGTERM 终止后以非零状态退出,错误被错误归类为 nonZeroExit,最终在 OpenCodeSupplier 中被映射为 RefreshError.parsingError——实际上超时和解析错误是完全不同的错误类型。

修复

  • ShellProcessRunner: timeoutTask 返回 Bool 标记进程是否因超时被终止,超时后抛出 ShellError.timedOut(在检查 exitCode 之前)
  • OpenCodeSupplier: nonZeroExit 分支增加 logger.error 记录实际的错误码和 stderr 前缀,方便排查真正的非零退出问题
  • ErrorSummary: 为 RefreshError 添加 CustomStringConvertible 扩展
  • 测试: 超时测试从宽松匹配改为严格验证 timedOut 及秒数

改动文件

文件 变更
ShellProcessRunner.swift 超时抛出逻辑修复
OpenCodeSupplier.swift 增加错误日志
ErrorSummary.swift CustomStringConvertible 扩展
ShellProcessRunnerTests.swift 测试严格化

- Add OpenCodeSupplier that shells out to 'opencode db' to read
  ~/.local/share/opencode/opencode.db for 5h/weekly/monthly usage
- Add Shell/ module (ShellProcessRunner, ShellCommand, ShellError)
  for async Process execution with timeout
- Add OpenCodeResponseParser with three-window reset algorithms
  (rolling 5h, UTC Monday, anchored monthly) and unit tests
- Extend shortName from 2 to 2-3 uppercase letters/digits to fit
  OpenCode dimension labels (OC5, MAX, etc.)
- Add dimension field to SlotViewData for per-window labeling
- Disable App Sandbox: required for Process.run() since macOS
  sandbox blocks child process creation. Trade-off documented in
  PRD §3.6, README, and opencode_go.md.
- Add .gitignore rule for *.zip build artifacts
- Update docs: PRD appendix C (status V1 supported), README
  providers table, project structure, test suites, security notes
…oExit

- ShellProcessRunner: timeoutTask returns Bool indicating whether process was terminated
- Throw ShellError.timedOut explicitly when timeout occurs, before checking exitCode
- OpenCodeSupplier: log stderr on nonZeroExit for better diagnostics
- ErrorSummary: add CustomStringConvertible conformance to RefreshError
- Tests: tighten timeout test to strictly expect timedOut with correct seconds
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.

1 participant