Skip to content

Plugin CLI commands crash when downstream pipes close early #2783

Closed

Description

@ariofrio

Summary

Plugin-contributed CLI commands crash with an unhandled EPIPE when a downstream command such as head closes stdout before the plugin's full output is written. A normal Unix pipeline should terminate quietly when its consumer has enough output.

Versions and environment

  • bb 0.40.0, desktop app
  • Reproduced against main at fa97c86a17d10b6e60d07bd6d1f524fe3cb6d929
  • macOS 26.5.1 (25F80)
  • Node.js 22.23.2

Steps to reproduce

  1. Find an existing Workflows run whose bounded history output exceeds the OS pipe buffer. For the verified run, bb workflows history <run-id> --limit 100 | wc -c reported 238,786 bytes across 46 JSONL records.
  2. Enable pipeline failure propagation with set -o pipefail.
  3. Run bb workflows history <run-id> --limit 100 | head -n 1 >/dev/null.
  4. The explicit proxy form, bb plugin run workflows history <run-id> --limit 100 | head -n 1 >/dev/null, reproduces identically.

Workflows is the enabled builtin:workflows plugin; no third-party plugin is required.

The accompanying pull request also includes a self-contained process-level reproduction: it starts a fixture HTTP server for the contribution and plugin CLI routes, launches the real CLI entry, returns output larger than the pipe buffer, and pipes it through head -n 1 under pipefail.

Expected vs actual

Expected:
No stderr; pipeline exits 0.

Actual:
node:events:497
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:87:19)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:170:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:89:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

Pipeline exits 1.

Evidence

The plugin proxy writes the returned string and rejects its callback error, but does not observe the stream's paired error event or classify EPIPE as normal early termination: writePluginCliOutput.

What you ruled out

  • The plugin handler does not write to process stdout; it returns a stdout string to bb.
  • The explicit bb plugin run … path fails identically, isolating the shared plugin-command proxy.
  • The failure reproduces with the built-in Workflows plugin, so it does not depend on a third-party plugin implementation.
  • bb thread list --json | head -n 1 exits cleanly in the same shell.
  • The bug remains on current main at fa97c86a17d10b6e60d07bd6d1f524fe3cb6d929 and reproduces in a self-contained CLI process test.
  • No matching open or closed issue was found for EPIPE plugin CLI.

Suggested priority and effort

Medium — affects plugin commands with sufficiently large output; retrying without an early-closing consumer is a workaround. Estimated effort is low.

  • I reproduced this on the latest release and on main.
  • I searched open and closed issues for the same problem.
  • This agent-written report ends with the required provenance.

AGENT GENERATED: by GPT-5 Codex

Activity

  1. added theissue type on Sep 1, 2026
  2. added
    plugins
    cli
    confirmed-repro
    on Sep 1, 2026
  3. bb-slop-cop commented on Sep 1, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    The open pull request already links to this issue, so I did not open a duplicate pull request.

  4. added a commit that references this issue on Sep 11, 2026
    370bf23
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

    cliconfirmed-reproplugins

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions