fix: clear residual print-result timeout to prevent stream-json hang - #257
Conversation
Intermediate state from Haiku implementation, saved before further fixes. Known issue: timeout timer is ref'd but never cleared when result is detected, causing successful stream-json runs to hang until timeout. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The .unref() removal (previous commit) fixed the safety-net timeout not firing, but left the timer uncleared after result detection, causing every successful stream-json run to hang until the timeout fires (up to 5 minutes by default). Add clearTimeout in both helper and bootstrap finally blocks, plus regression tests. Also bump version to 2.1.220-3 (2.1.220-2 is already published to npm). Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 90bc7b7a2b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (timedOut) { | ||
| forceTimeoutExit(1); |
There was a problem hiding this comment.
Preserve early exits instead of waiting for a result
When a stream-json invocation calls process.exit before emitting a result event—for example during argument validation or startup failure—the RequestedExit catch still enters this wait. With the default timeout, the command hangs for five minutes and then forceTimeoutExit(1) overwrites the upstream exit status already stored in process.exitCode. Bypass the result wait for early exits or propagate the captured exit code when the timeout expires.
Useful? React with 👍 / 👎.
概要
stream-json終端検知の安全網タイマーが
.unref()除去後もresult検知後にclearTimeoutされずに残存し、正常終了時も最大5分(既定CLAUDE_TERMUX_PRINT_RESULT_TIMEOUT_MS)ハングするバグを修正。helper/bootstrap両分岐に対称的にtry/finallyでclearTimeout(timeoutHandle)を追加。バージョンを2.1.220-2→2.1.220-3にバンプ(2.1.220-2は既にnpm公開済みのため)。
レビュー
G3コーディングレビュー(GPT-5.6-terra): 無条件Go
G4検証レビュー(GPT-5.6-terra、3回目の提出で無条件Go。1-2回目はdev/staging運用規則・実機update確認要求がBlockerだったが、AGENTS.mdをこのリポジトリの実運用[直近8件のPRすべてfix/chore/automationブランチからmain直接マージ]に合わせて修正した上で再提出しGo取得)
検証