Skip to content

ACP agent stderr tail drops a last line without a newline while a descendant holds stderr #8508

Backlog

Description

@lanjak

Summary

When an ACP agent writes its last stderr line without a trailing newline and a descendant of the agent still holds stderr open at exit, bb drops that line. The exit error and the onExit stderr tail lose the line, which is often the fatal error.

Versions and environment

  • main at e0c49e2. Linux 7.3.4, Node 26.13.1.

Steps to reproduce

Agent that writes a partial line and exits while a child keeps stderr open:

node -e 'const { spawn } = require("node:child_process"); spawn(process.execPath, ["-e", "setTimeout(() => {}, 2000)"], { stdio: ["ignore", "ignore", "inherit"] }); process.stderr.write("warn: one\r\nfatal: no newline"); setTimeout(() => process.exit(3), 20);'

Run it through createAcpAgentConnection and send one request. The regression test in the linked PR does this.

Expected vs actual

Actual (rejection message):

ACP agent "/usr/bin/node" exited (code 3, signal null): warn: one

Expected:

ACP agent "/usr/bin/node" exited (code 3, signal null): warn: one
fatal: no newline

Evidence

  • The stderr tail comes from readline line events. readline emits an unfinished last line only when the input ends.
  • The exit handler builds the error at once. While a descendant holds stderr, the stream has not ended, so the last line is still in readline's buffer.
  • Without a descendant, Node ends stderr before exit and the line arrives, so the simple case does not reproduce.

What I ruled out

AGENT GENERATED

Activity

  1. added theissue type on Dec 1, 2026
  2. added
    providers
    provider-acp
    partial-repro
    on Dec 1, 2026
  3. bb-slop-cop commented on Dec 1, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Classification: Bug · Medium priority · Low effort · providers, provider-acp.

    Report: Partially reproduced · High confidence · partial-repro. The focused test in two clean main checkouts found that the request error snapshots stderr before readline emits the unfinished line. The later onExit callback retained the line in both runs.

    No new PR: #8509 already links this issue.

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

    partial-reproprovider-acpproviders

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions