Repository navigation
Conversation
readline gives a line without a newline only when stderr ends. When a descendant of the agent still held stderr open at exit, the last line, often the fatal error, was missing from the exit error and the onExit tail. Read stderr with an own line buffer and add the unfinished line to the tail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
The ACP agent stderr tail came from
readlinelineevents. readline gives an unfinished last line only when stderr ends. When a descendant of the agent held stderr open, theexithandler built the error before that, so the last line was lost. That line is often the fatal error.What changed
packages/provider-bridge-acp/src/bridge/agent-connection.ts: read stderr with aStringDecoderand an own split on\r\n,\rand\n, the same separators as readline. A\rat the end of a chunk stays in the buffer, so a\r\nsplit across chunks gives one line. The unfinished line is added to the tail in the exit path and in the stdin-closed path. The 40-line cap is unchanged, and a big chunk pushes only its last 40 lines. The unfinished line keeps only its last 4,096 characters, so each chunk costs time in proportion to its own size (50 MB with no line ending: 11 ms; an uncapped buffer took about 10 s in review), and a huge line does not go into the error message.stderrChunks, so inonExitit can come before the unfinished line. Show the ACP agent's full stderr when it exits #8504 moves that note out ofstderrChunks; with both merged, the order is right.Docs: no doc describes the stderr tail.
How you verified
Base: e0c49e2.
keeps a last stderr line without a newline while a descendant holds stderr openwarn: onekeeps the stderr tail bounded when the agent redraws a line with carriage returns(500\rredraws)keeps only the end of a very long stderr line that has no newline(100,000 characters)pnpm exec turbo run test typecheck lint --filter=@bb/provider-bridge-acp: 647 passed, 4 skipped; typecheck and lint clean. Full package suite 5 of 5 runs green.node packages/plugin-sdk/scripts/check-npm-version-guard.mjs: PASS (0.6.215 is not on npm yet), so no SDK version bump.exitbefore it has read stderr that the agent already wrote. That race is separate and older.pgrep).Fixes #8508