Bug
The Codex companion app-server broker process (app-server-broker.mjs) persists indefinitely after the Claude Code session that spawned it exits. Found a stale broker (3 processes, ~185 MB) running 5+ hours after the originating session ended.
Root Cause
The plugin has a well-implemented session-lifecycle-hook.mjs with handleSessionEnd() that sends broker/shutdown — but this hook doesn't appear to fire reliably. The broker itself has no idle timeout — it only shuts down upon receiving an explicit broker/shutdown RPC or SIGTERM/SIGINT.
When the session-end hook fails to fire (or the session crashes/is killed), the broker runs forever.
Suggested Fix
Add an idle timeout to app-server-broker.mjs as a defensive fallback. If no RPC messages are received for N minutes (e.g., 15-30), the broker should self-terminate. This complements the existing session-end hook rather than replacing it.
The lifecycle hook approach is correct, but defense-in-depth with an idle timeout would prevent orphaned brokers when the hook doesn't fire.
Environment
- Ubuntu 22.04, Claude Code CLI
@openai/codex-plugin-cc v1.0.2
- Broker was spawned for
intake-portal project, outlived the session by 5+ hours
Workaround
Manually killing the broker processes after session exit.
Bug
The Codex companion app-server broker process (
app-server-broker.mjs) persists indefinitely after the Claude Code session that spawned it exits. Found a stale broker (3 processes, ~185 MB) running 5+ hours after the originating session ended.Root Cause
The plugin has a well-implemented
session-lifecycle-hook.mjswithhandleSessionEnd()that sendsbroker/shutdown— but this hook doesn't appear to fire reliably. The broker itself has no idle timeout — it only shuts down upon receiving an explicitbroker/shutdownRPC or SIGTERM/SIGINT.When the session-end hook fails to fire (or the session crashes/is killed), the broker runs forever.
Suggested Fix
Add an idle timeout to
app-server-broker.mjsas a defensive fallback. If no RPC messages are received for N minutes (e.g., 15-30), the broker should self-terminate. This complements the existing session-end hook rather than replacing it.The lifecycle hook approach is correct, but defense-in-depth with an idle timeout would prevent orphaned brokers when the hook doesn't fire.
Environment
@openai/codex-plugin-ccv1.0.2intake-portalproject, outlived the session by 5+ hoursWorkaround
Manually killing the broker processes after session exit.