Move this.emit("error", err) after the pending-rejection loop in
handleProcessError, matching handleProcessExit's order. Without this,
emit("error") with no listeners throws synchronously, skipping
cleanup of pending requests.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add "jsonrpc": "2.0" to all JSON-RPC requests, notifications, and
approval responses for spec compliance
- Place flags before positional threadId in resume command for CLI
parser compatibility (codex resume --flags <threadId>)
- Add test assertions for jsonrpc field and flag ordering
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove additive cached_tokens/reasoning_tokens from cost calculation
(they are subsets of input_tokens/output_tokens per OpenAI API convention)
- Wrap entire connect() body in try/catch so connecting flag resets if
spawn() throws synchronously (EMFILE, ENOMEM)
- Add test for spawn-throws-synchronously recovery
- Update cost assertions to reflect correct non-additive token counting
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Reset closed flag after failed connect() so client can retry
- Wrap binary resolve guard in try/finally to clear on rejection
- Fix duplicate import and unused variable lint errors in tests
- Add test: client retries connect after transient handshake failure
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes 6 issues flagged by Cursor Bugbot on PR #188:
1. sessionFileMatchesCwd reads only first 4 KB via open()+read() instead of
loading entire rollout file into memory (Medium)
2. Binary resolution race condition: added promise guard to prevent
concurrent resolveCodexBinary() calls (Low)
3. Concurrent connect() calls: added connecting guard to prevent
orphaned child processes (High)
4. connect() failure cleanup: wrap initialize() in try/catch that
calls close() on failure (Medium)
5. readline cleanup on process exit/error: close readline in both
handleProcessExit and handleProcessError (Medium)
6. stderr pipe drain: call stderr.resume() to prevent child blocking
when stderr buffer fills (High)
All 177 tests pass, typecheck clean.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>