Skip to content

tui: plugin EPIPE unhandled rejection kills the client silently (no diagnostic) #54575

Closed as not planned

Description

@seppaleinen

Summary

A plugin write that fails with EPIPE (the pipe to the parent was closed) produces an unhandled Promise rejection that terminates the opencode TUI client silently — the process exits with no error surfaced in the TUI. Plugin failures present as random, unexplained client crashes.

Environment

  • opencode version: 2.0.25 (Homebrew, channel latest)
  • OS: macOS Darwin 27.0.0 (arm64)
  • Terminal: ghostty (TERM xterm-256color, COLORTERM=truecolor)
  • Shell: /bin/zsh
  • Install/channel: latest (Homebrew)
  • Active plugins: opentmux (local), opencode-plugin-litellm@latest, a local herdr TUI plugin (v1-era @opencode-ai/plugin API at the time of the crash)

Reproduction

  1. Install a plugin whose code writes to a file descriptor that has been closed by the parent (observed: a v1-era TUI plugin writing during client startup when the parent had already closed the pipe).
  2. Start opencode.
  3. The client exits immediately, with no error shown in the TUI.

Expected Behavior

A failing plugin write is surfaced as a plugin error — e.g. a "failed to load plugin" message, a logged non-fatal error, or at minimum an actionable exit diagnostic. An unhandled rejection in plugin code should not take down the whole client silently.

Actual Behavior

The EPIPE write throws; the rejection is unhandled; the opencode client process dies silently. No error is visible to the user — it looks like an unexplained crash at startup.

Additional Context

  • Triggered during an opencode v1→v2 migration (2026-10): the offending plugin used the old @opencode-ai/plugin API and wrote during load; under opencode 2.0.25 it hit EPIPE and killed the client.
  • Local workaround that resolved it: port the plugin to the v2 @opencode/plugin API and wrap writes in try/catch with error/close handlers.
  • Suggestion: a process-level unhandledRejection handler in the TUI that logs the rejection (ideally with plugin context) and keeps the client alive, or exits with a clear diagnostic instead of dying silently.

Activity

  1. opencode-agent commented on Oct 11, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report! Before we can try to reproduce this, could you share a bit more?

    1. The error itself. You mention EPIPE and an unhandled rejection. Where did you see them? Please paste the full error and stack trace, plus the relevant lines from the OpenCode log for that run (~/.local/share/opencode/log/).
    2. A minimal reproducing plugin. A short snippet of the plugin code that did the failing write: which stream or file descriptor it wrote to (stdout/stderr, a socket, a child process pipe, …), and where in the plugin it ran (at load time, in a hook, …). If you can, please also check whether it still happens with a plain v2 plugin that does the same write without your try/catch.
    3. How the plugin was loaded. Was it listed under plugin in opencode.json or tui.json, or loaded from .opencode/plugin(s)/? And which command did you run: plain opencode, or something like opencode run/attach?

    For context: the v2 CLI already installs handlers for unhandled rejections and uncaught exceptions that log the error instead of crashing, and it ignores EPIPE on stdout. So the exact error and stack would help us find where the failure really escapes.

    You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done.

    These issues look related (ordered by likelihood), though none seems to be exactly the same problem:

  2. opencode-agent commented on Oct 14, 2026

    @opencode-agent
    Contributor

    We're closing this for now, since we haven't heard back and can't reproduce the crash without more detail. In particular, we'd need the actual EPIPE error and stack trace (or the log lines from ~/.local/share/opencode/log/) and a minimal plugin snippet that triggers it. The v2 CLI already logs unhandled rejections instead of crashing, so those details are what would show where this one gets through.

    If it happens again on a current v2 release, please comment here with that information, or open a new issue that links back to this one, and we'll take another look. Thanks for reporting it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions