Issue
When a codex-companion.mjs task --background task-worker process exits due to broker JSON-RPC socket close/reset, runTrackedJob's catch block is never reached. The job stays permanently in status: "running" in state.json with a now-dead PID.
Reproduce
- Start a long-running codex task in background mode
- Kill the broker mid-task OR cause broker socket reset (e.g., transient network blip on app-server connection)
- task-worker process dies silently
codex status reports "running" indefinitely
Evidence (from local instance)
- task-worker spawn: codex-companion.mjs lines 641-679 (
spawnDetachedTaskWorker with detached: true, stdio: "ignore")
- State write on completion:
lib/tracked-jobs.mjs lines 153-203 — only catch path writes failed status
- Two ghost-running tasks observed today with last activity timestamps minutes before broker reset, then no log entries, no error, dead PIDs
Proposed fix
Add process.on('exit'/'uncaughtException'/'unhandledRejection') handler in handleTaskWorker that synchronously writes status: "failed" to the job file before exit. Without this, operators cannot distinguish actively-running tasks from dead ones.
Workaround
Operators must ps -p <PID> to check if the worker is alive. If dead, manually mark task as failed in state.json.
Environment: codex-cli 0.129.0, Linux x86_64 (WSL2 Ubuntu 24.04), npm 11.x.
Issue
When a
codex-companion.mjs task --backgroundtask-worker process exits due to broker JSON-RPC socket close/reset,runTrackedJob's catch block is never reached. The job stays permanently instatus: "running"in state.json with a now-dead PID.Reproduce
codex statusreports "running" indefinitelyEvidence (from local instance)
spawnDetachedTaskWorkerwithdetached: true, stdio: "ignore")lib/tracked-jobs.mjslines 153-203 — only catch path writes failed statusProposed fix
Add
process.on('exit'/'uncaughtException'/'unhandledRejection')handler inhandleTaskWorkerthat synchronously writesstatus: "failed"to the job file before exit. Without this, operators cannot distinguish actively-running tasks from dead ones.Workaround
Operators must
ps -p <PID>to check if the worker is alive. If dead, manually mark task as failed in state.json.Environment: codex-cli 0.129.0, Linux x86_64 (WSL2 Ubuntu 24.04), npm 11.x.