Skip to content

Broker process not cleaned up on session exit — no idle timeout #108

Description

@NewAiCoder

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions