Skip to content

[BUG] SIGINT handler prevents opencode Ctrl+C session id output #187

Description

@ndj888

Bug Description
oc-codex-multi-auth appears to install a SIGINT handler that calls process.exit(0) after plugin cleanup. This can preempt opencode's own Ctrl+C/shutdown cleanup path. In my case, after pressing Ctrl+C to exit opencode, opencode no longer echoes/prints the session id as it did before.

The behavior points to the plugin taking ownership of process termination on Ctrl+C instead of letting the host opencode process finish its own shutdown handling.

Steps to Reproduce

  1. Install/use opencode with oc-codex-multi-auth enabled in the opencode config.
  2. Start an interactive opencode session.
  3. Let opencode complete a task.
  4. Press Ctrl+C to exit.
  5. Observe whether opencode prints/echoes the session id during shutdown.

Expected Behavior
The plugin should run any needed cleanup, but opencode should still be able to complete its normal Ctrl+C/shutdown behavior, including printing/echoing the session id.

Actual Behavior
With oc-codex-multi-auth enabled, pressing Ctrl+C exits without opencode printing/echoing the session id.

Environment

  • opencode version: 1.17.13 installed via Homebrew
  • Plugin version: 6.5.0
  • Operating System: macOS darwin arm64
  • Node.js version: v26.0.0

Logs
No request logs attached. This appears to be local signal/shutdown behavior rather than a backend request issue.

Compliance Checklist
Please confirm:

  • I'm using this plugin for personal development only
  • I have an active ChatGPT Plus/Pro subscription
  • This issue is not related to attempting commercial use or TOS violations
  • I've reviewed the FAQ and Troubleshooting sections

Additional Context
The likely cause is in dist/lib/shutdown.js:

const handleSignal = () => {
  void runCleanup().finally(() => {
    process.exit(0);
  });
};

process.once("SIGINT", handleSignal);
process.once("SIGTERM", handleSignal);

Because the plugin calls process.exit(0) from its SIGINT handler, the host opencode process may not get a chance to finish its own shutdown/exit handling.

I tested a local patch that keeps plugin cleanup on SIGINT but does not call process.exit() for SIGINT. In a small simulation, cleanup still ran and SIGINT no longer forced process exit:

const handleSignal = (signal) => {
  void runCleanup().finally(() => {
    if (signal === "SIGTERM") {
      process.exit(0);
    }
  });
};

process.once("SIGINT", () => handleSignal("SIGINT"));
process.once("SIGTERM", () => handleSignal("SIGTERM"));

Suggested fix: avoid calling process.exit() from the plugin's SIGINT handler. Let opencode remain responsible for process termination on Ctrl+C, while the plugin still performs cleanup.

Related but not a duplicate: #176 discusses abort behavior around client teardown, but this report is specifically about the plugin's SIGINT handler swallowing opencode's exit/session-id behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions