openai / openai/codex-plugin-cc
`npm test` leaves a detached broker and a fake app-server behind for every test workspace
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 33.3k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
What happens
Every codex-companion invocation that reaches the app-server calls CodexAppServerClient.connect(cwd), which starts a detached, unref'd app-server-broker.mjs serve for that workspace unless CODEX_COMPANION_APP_SERVER_ENDPOINT is set or disableBroker is passed (plugins/codex/scripts/lib/app-server.mjs, connect; broker-lifecycle.mjs, ensureBrokerSession). The broker keeps its codex app-server child alive, has no idle timeout, and only stops on broker/shutdown, which the SessionEnd hook sends.
The test suite creates a fresh temp workspace per test and never sends broker/shutdown, so each full run leaves roughly a hundred broker + fake-app-server pairs parented to launchd. On a developer machine they accumulate silently: after eight full runs on macOS I counted 1,108 fake codex app-server fixtures and 555 brokers, 36 GB resident, all idle at 0 % CPU. Nothing in CI notices because the runner is thrown away.
Observed on main at db52e28, node 22.17.0, macOS.
Reproduction
npm test >/dev/null 2>&1
ps -axo pid,ppid,command | grep -c "codex-plugin-test-.*/codex app-server"
# ~100 per run, ppid 1, still there an hour later
Possible fix
- A
t.afterintests/helpers.mjsor the fixture that reads the broker session file for each temp workspace (loadBrokerSession(cwd)) and sendsbroker/shutdown, or kills the recorded pid; or - a suite-wide env such as
CODEX_COMPANION_APP_SERVER_ENDPOINT=unix:/nonexistent.socksowithAppServerfalls back to the spawned client, for the tests that do not exercise the broker; or - an idle timeout in the broker (say 30 minutes without a client), which would also help real sessions whose SessionEnd hook never runs (crashed terminal, killed IDE).
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 with tests/helpers.mjs and the fixture paths around loadBrokerSession(cwd), then run npm test and the supplied process check to reproduce the orphaned broker/app-server pairs. Trace the existing broker/shutdown path in plugins/codex/scripts/lib/app-server.mjs and broker-lifecycle.mjs. Done means the test run leaves no per-workspace broker or fake app-server processes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- devtools, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100