Repository navigation
Description
Bug Description
When closing a chat tab in Codex Desktop, the codex app-server --listen stdio:// and its parent node_repl processes are not terminated, accumulating zombie processes over time.
Process Tree
Codex Desktop (Electron)
└── node_repl
└── codex app-server --listen stdio://
Each new chat tab spawns a fresh set of these processes. After closing tabs, they remain running indefinitely with 0% CPU and 0 children.
Steps to Reproduce
- Open Codex Desktop
- Open multiple chat tabs (e.g., 10)
- Close most of them, keeping only 1-2
- Check processes:
ps aux | grep 'codex app-server' - Observe that nearly all processes from closed tabs remain alive
Observed Behavior
$ ps aux | grep 'codex app-server' | grep -v grep | wc -l
9
Only 1 of the 9 processes had active children (26 MCP sub-processes). The other 8 were idle zombies consuming memory.
Root Cause Analysis
The app-server in stdio mode exits only on stdin EOF (codex-rs/app-server-transport/src/transport/stdio.rs:68):
// codex-rs/app-server-transport/src/transport/stdio.rs:43-80
// stdin reader loop — blocks on lines.next_line().await
// EOF triggers ConnectionClosed eventAnd shutdown_when_no_connections is set based on stdio mode (codex-rs/app-server/src/lib.rs:662-663):
let single_client_mode = matches!(&transport, AppServerTransport::Stdio);
let shutdown_when_no_connections = single_client_mode;The leak occurs because:
- When Desktop closes a tab,
node_replmay be killed (SIGKILL) without gracefully closing the stdin pipe tocodex app-server - Or
node_replexits but the stdin fd is orphaned — the kernel doesn't always reclaim it immediately codex app-serverblocks forever onlines.next_line().await, never receiving EOF- There is no heartbeat/timeout mechanism to detect this zombie state
- Daemon uses
setsid()(app-server-daemon/src/backend/pid.rs:171-176) creating independent process groups, so SIGTERM doesn't cascade to children
Suggested Fixes
Fix 1: Add heartbeat/timeout in stdio transport
Add a periodic check in stdio.rs — if no data received on stdin for N minutes, treat as EOF and shut down.
Fix 2: PID file tracking for stdio mode
Daemon mode already uses PID files (pid.rs) for process lifecycle management. Stdio mode should similarly track child PIDs so orphaned processes can be discovered and cleaned up.
Fix 3: Desktop-side fix (Electron)
Ensure that when a tab is closed, node_repl gracefully closes the stdin pipe to codex app-server before terminating, giving it a chance to shut down cleanly.
Environment
- macOS Darwin 25.5.0
- Codex Desktop 26.602.40724
- Codex app-server started via
--listen stdio://
Workaround
Manually kill zombie processes:
# Find idle app-server processes (0 children, 0% CPU)
ps aux | grep 'codex app-server' | grep -v grep
# Kill specific PIDs
kill <pid>
Activity
github-actions commentedon Jun 6, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
vladysmd commentedon Oct 6, 2026
Follow-up: retained native CUA workers and nested App Servers on macOS
Related report: openai/codex#26773.
Observed on 2026-10-06:
mcp_servers.node_replwas disabled. Native CUA workers were still present.This is a retention observation, not a controlled reproduction proving that every retained worker belongs to a closed chat. Per-process chat ownership is unavailable to the current client. No processes were signaled and no signed application files were modified. Reported heat and earlier crashes are not causally attributed to this process snapshot.
Separate read-only App Server clients can read terminal child turns, but process-local diagnostics and a new client's unsubscribe cannot prove retirement of Desktop's existing connections. The native-default stable and beta update-feed queries both listed this installed build as their newest entry; account-specific cohorts may differ.
Is there a supported owner-bound API to dispose of a completed chat's native CUA worker and any nested App Server without restarting Desktop or interrupting other chats? If this retention has a maintained fix, which Desktop build contains it? A documented expected lifetime for idle/subscribed workers would also help distinguish retained sessions from abandoned workers.
No logs, chat contents, account identifiers, credentials, local user paths or task UUIDs are included.
TyceHerrman commentedon Oct 19, 2026
I captured a related leak on macOS Apple Silicon with Desktop 26.1013.40934, bundled CLI 0.163.0-alpha.10.2. Here the parent is a computer-history MCP worker, rather than
node_repl:The monitor records the history worker exiting while its Codex child survives and becomes a PID-1 orphan, retaining about 1 GiB physical footprint.
On October 19, 2026:
The onset coincided with
thread/resume, MCP initialization, and computer-history cancellation (quit_reason=Cancelled). That is correlation; I have not established the failing code path or a minimal reproduction.Measurements use
proc_pid_rusagephysical footprint, not summed RSS. No monitored processes were killed or restarted, and no raw logs or private task data are attached.if this issue shoudn't cover cleanup of backends launched by
computer-history mcp, I can create new issue for thisUpdate: paired startup stacks. Later captures show three computer-history-launched backends inside Codex authentication loading → age decryption → scrypt at startup ages of 22–30 seconds; paired helpers were waiting for the nested backend’s
initializeresponse. A ~30-second handshake timeout was followed by helper exit and PID-1 orphaning; the children persisted for over eight minutes before manual cleanup. The auth file specifies scrypt work factor 20, requiring a 1 GiB buffer—matching #38435’s allocation mechanism. Concurrent decryptions worsening startup time is plausible, but unproven; orphan cleanup is a separate defect.Update: direct Keychain workaround
After preserving the config and encrypted-auth backup, I signed in with
features.secret_auth_storage=false, keptcli_auth_credentials_store = "keyring", and then persisted the feature setting and restarted Desktop.Verified:
login statussucceeded in 0.07 seconds, with 40 MiB maximum RSS and 15.3 MiB peak physical footprint.This supports direct Keychain storage as a local workaround for the earlier encrypted-auth startup/decryption problem. It does not establish that orphan cleanup is fixed.