Surface error cause chain in CLI error messages - #1190
Merged
ymichael merged 2 commits intoAug 10, 2026
Conversation
ymichael
added a commit
that referenced
this pull request
Aug 10, 2026
…1218) Fixes #1216. ## Summary The unknown-command plugin probe caught its fetch error with a bare `catch`, so every failure — ECONNREFUSED, EPERM from a sandboxed shell, a timeout — printed the same "bb isn't running — open the bb app, then re-run this command." That message asserts a fact the code had no evidence for, and agents act on it: they declare a healthy bb dead and abandon queued work. The probe now keeps the thrown error, and `describeUnreachableServer` derives the message from the cause chain: - `ECONNREFUSED` — the only evidence bb is actually down — keeps the existing guidance, now naming the address: `bb is not running at <url> — open the bb app, then re-run this command.` - `EPERM`/`EACCES`: `Cannot reach bb at <url>: EPERM — the connection was blocked. bb may still be running; check sandbox or firewall rules for this shell.` - Timeout: `bb did not respond at <url> within 2000ms — it may be busy or unreachable.` - Anything else prints the unwrapped cause chain. The related built-in-command formatter fix (`.cause` discarded by `getErrorMessage`) is #1190; this covers the probe path, which discards the error before any formatter runs. --------- Co-authored-by: Michael Yong <wrong92@gmail.com>
ymichael
force-pushed
the
unwrap-error-cause-chain-in-cli
branch
from
August 10, 2026 23:02
e8464b0 to
32cfa97
Compare
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.
Summary
Fixes #1189. Node's fetch rejects with a generic
TypeError: fetch failedand keeps the actionable socket error (for example,connect EPERM 127.0.0.1:38886) under.cause. For multi-address connections such aslocalhost, that cause can be anAggregateErrorwhose.errorscontain the per-address failures.The CLI's
getErrorMessagepreviously read only the outer.message, so distinct failures all printed the same uninformativeError: fetch failed.Walk the error graph when formatting CLI errors:
.causechains;AggregateError.errorsentry;A sandbox-blocked connection now prints the underlying
EPERMdetail, including when it is one attempt in a multi-address connection. The existing ECONNREFUSED mapping to "Cannot connect to BB server" is unchanged.Verification
pnpm exec turbo run typecheck --filter=@bb/cli --forcepnpm exec turbo run test --filter=@bb/cli --forcepnpm exec turbo run build --filter=@bb/cli --force