fix(test): fake codex app-server exits when its parent dies (leak fix) - #1035
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe pull request adds a deterministic fake ChangesFake Codex app-server
Estimated code review effort: 4 (Complex) | ~45 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/fake-codex-server.ts`:
- Around line 51-53: Update notify to include the JSON-RPC 2.0 version in every
notification, and remove the fake-exit-ack stdout emission from the shutdown
path around shutdownRequested. Keep stdout limited to valid protocol messages;
tests should detect graceful shutdown via the child process exit rather than an
out-of-band marker.
- Around line 140-143: Move the startupDelayMs wait from the general request
path into the method === "initialize" branch in the fake server request handler,
so only initialization is delayed while thread and turn operations proceed
without the startup delay.
- Around line 206-270: Update the terminal-event flow in the fake server’s
scripted turn handler to construct one terminal payload containing the shared
status and failure details, including the error information for failed turns.
Emit that payload once by default, suppressing the later emission when
emitTerminalFirst is enabled, and emit a second identical payload only when
duplicateTerminal is explicitly enabled; preserve the existing notification,
approval, and heldUntilInterrupt behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 2733d23e-cb96-4d11-b2fe-a5d722feb2c9
📒 Files selected for processing (1)
tests/fake-codex-server.ts
[GD] Verdict: approve-commentTLDR
Full reviewUsefulnessThe PR introduces BugsNone confirmed. Reviewed against the required lenses:
SecurityPass. Scope surfaces Spec and StandardsSpec source: PR body + originating leak-fix request. Implemented as specified and Semantic propagation
Reviews triaged
Fixes this session
|
…tartup delay, separate terminal modes
[GD] Verdict: approve-commentTLDR
Full reviewUsefulnessThe PR introduces BugsNone confirmed. Reviewed against the required lenses:
SecurityPass. Scope surfaces Spec and StandardsSpec source: PR body + originating leak-fix request. Implemented as specified and CodeRabbit round (fixed in
|
|
Merged — the fake codex app-server now exits when its parent dies, ending the macOS pipe-EOF CI hangs and the Windows orphan pileup. The Fabric rebase will adopt this file version. |
Why
The
fake-codex-servertest helper (deterministic fake of thecodex app-server,spawned as a real child process by the Fabric CI tests) only exited via a stdin-EOF
handler. When the test worker that spawned it is killed hard (which
bun test --isolatedoes at file end), that EOF is not reliably delivered onWindows — the child outlives its worker.
What was found
Diagnosis from a 30-minute macOS CI freeze (PR #1005) and a local Windows hang:
test output for 30 minutes, then the job timeout killed it. At job end the
runner cleaned up exactly one orphaned
bunprocess (pid 4812). Cause: aleaked child keeps the finished file worker's stdout pipe open.
bun testwaits for pipe EOF, so it waits until the timeout.
local machine, 19 orphaned test processes from several aborted suite runs
(including
fake-codex-serverchildren) held test ports;scripts/test.tswaited up to 45 minutes for competing runners and the suite appeared hung.
mocked or capped with a timeout. The hanging element was always the surviving
child process, never the test.
Consequences before
until a manual rerun).
machine, suites crawl from ~10 min to 45+ min or hang completely.
After the fix
The file now contains a parent-death watchdog: every 500 ms the spawner PID
(
process.ppid) is checked viaprocess.kill(pid, 0); once it is gone, the childexits immediately — even without stdin EOF and even in the
hangOnShutdownscript(the explicit force-kill test still wins first). The timer is
unref'd and doesnot keep the child artificially alive.
Verified:
fabric-codex-jsonrpc+fabric-codex-adapter):39/39 green
< 3 s after the parent dies
fake-codex-serverorphans behindScope note
tests/fake-codex-server.tscurrently only exists in the unmerged Fabric branch(
fab-03/codex-runtime). This PR introduces the file ondevindependently —including the watchdog. The later Fabric rebase will adopt this version (the
branch is 178 commits behind
devanyway).Summary by CodeRabbit