openai / openai/codex-plugin-cc
Robustness: detached-worker spawn error handling, dead-worker reconciliation, atomic + serialized state writes
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 33.3k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Thanks for the plugin. While hardening our setup we hit several robustness issues in the job-state / worker lifecycle (v1.0.4) that can silently lose job records or leave jobs wedged. File:line are against the v1.0.4 tag.
Medium
-
Detached worker spawn has no
errorhandler —scripts/codex-companion.mjs,spawnDetachedTaskWorker.child.unref()is called with nochild.on("error", …); a failed spawn (ENOENT/EACCES) goes undetected, the job is recorded withpid: null, and a subsequent cancel silently no-ops. Suggest attaching anerrorhandler that marks the jobfailed. -
Crashed worker stuck
runningforever —scripts/codex-companion.mjs,waitForSingleJobSnapshot. Status is polled with no PID-liveness check, so aSIGKILL'd worker never self-transitions (thecatchthat writesstatus: "failed"never runs). Suggest aprocess.kill(pid, 0)liveness probe (ESRCH → failed) or a timeout→failed fallback in the read path. -
state.jsonwritten non-atomically, and the read-modify-write is unserialized —scripts/lib/state.mjs(saveState,writeJobFile,updateState). Two distinct problems:- Plain
fs.writeFileSynccan be observed mid-write;loadStatethen hits itscatchand silently returns empty state, dropping all job records. Suggest temp-file +fs.renameSyncfor an atomic replace. updateStatedoesloadState → mutate → saveStatewith no lock. Concurrent writers — parent enqueue, the worker's progress updates (createJobProgressUpdater), and the SessionEndcleanupSessionJobsinscripts/session-lifecycle-hook.mjs— each load, patch their own copy, and last-writer-wins drops other jobs. Suggest a lock (or compare-and-swap) around the RMW. Repro: ~25 concurrent writers adding distinct jobs → most are lost.
- Plain
Low
generateJobIdusesMath.random()(scripts/lib/state.mjs) — prefercrypto.randomUUID()/crypto.randomBytes.ensureGitRepositoryruns twice per review.handleResult/handleTaskResumeCandidateare not awaited.status --waitexits0on timeout (reads as success);readJobFilehas no JSON parse guard.
Happy to send a PR for any of these if useful.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in scripts/codex-companion.mjs at spawnDetachedTaskWorker and waitForSingleJobSnapshot, then inspect saveState, writeJobFile, updateState, and loadState in scripts/lib/state.mjs. Reproduce the concurrent-writer loss and failed or killed worker cases described in the issue. Done means worker failures become visible, dead jobs do not remain running indefinitely, and state writes are atomic and serialized without dropping records.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100