Skip to content

Stop bb-app's CLI entry from re-launching itself through BB_CLI - #6436

Merged
ymichael merged 1 commit into
get-bb:mainfrom
ratulsarna:fix/bb-cli-launcher-loop
Oct 28, 2026
Merged

ymichael merged 1 commit into
get-bb:mainfrom
ratulsarna:fix/bb-cli-launcher-loop

Conversation

@ratulsarna

@ratulsarna ratulsarna commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

#6194 made script automations set BB_CLI to the public launcher, ~/.bb/bin/bb. That launcher runs bb-app/dist/bb.js. runBundledCliCommand runs BB_CLI whenever it is set and had no loop guard, so each bb call started the launcher again, without end, until the server ran out of memory. See #6435.

What changed

  • runBundledCliCommand marks the BB_CLI child with BB_CLI_REEXEC=1. When it sees that mark, it runs the bundled CLI instead. This is the same handshake apps/cli/src/bb-cli-reexec.ts already uses.
  • The marker name now lives in @bb/config/cli-command for bb-app. The CLI keeps its own copy because its startup graph must not load packages/config (startup-graph.test.ts).

How you verified

  • New bb-app test that runs the entry again with the env from the first run. It fails on main with expected 1 to be +0 and passes with this change.
  • turbo run typecheck --filter=bb-app --filter=@bb/config --filter=@bb/cli passed. turbo run test --filter=bb-app passed, 220/220.
  • Ran the loop through a real generated launcher with BB_CLI pointing back at it. It now exits once with the right output and exit code. Before, it grew to 19-33 processes in 3s.

Fixes #6435

🤖 Generated with Claude Code

AGENT GENERATED

Automation scripts now receive BB_CLI pointing at the public bb launcher,
which runs bb-app's entry again. The entry forwarded to BB_CLI with no
guard, so each bb call spawned itself until the server ran out of memory.
The entry now marks the override child with BB_CLI_REEXEC and runs the
bundled CLI when that marker is set, matching the CLI's own guard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 544e49c into get-bb:main Oct 28, 2026
92 of 94 checks passed
@ymichael ymichael mentioned this pull request Oct 30, 2026
ymichael added a commit that referenced this pull request Oct 30, 2026
## Human comments

## What was wrong

desktop 0.48.0 shipped #6194 but not its fix, #6436, which merged two
hours after the release. On 0.48.0, any script automation that calls
`bb` starts `bb` again without end (#6435, #6557), and users are hitting
it: one Discord report had about 3,750 nested `bb thread show` processes
on a 48 GB Mac. `bb-app` and `@bb/desktop` are still at 0.48.0, so the
publish and desktop workflows can't ship the fix.

## What changed

- `packages/bb-app/package.json`, `apps/desktop/package.json`: 0.48.0 →
0.48.1 (`node scripts/bump-version.mjs --patch`).
- No release notes for this patch: `CHANGELOG.md` and
`changelog-metadata.ts` are unchanged, as with 0.47.1.

The release commit sits directly on `a19a8eeffd`, the current `main`, so
0.48.1 ships all 98 commits since 0.48.0. These include two protocol
bumps (`HOST_DAEMON_PROTOCOL_VERSION` 256 → 258) and no database
migrations.

## How you verified

- `node .github/workflows/check-version-lockstep.mjs`: `bb-app=0.48.1
@bb/desktop=0.48.1`.
- `git diff --check` is clean.
- Reproduced the loop on the published `[email protected]` with `BB_CLI`
pointed at a generated launcher: `--version` printed nothing, and 65
processes were running after 3 seconds. The nightly
`0.48.1-nightly.40912875657.1`, which contains #6436, is the build that
has the fix in the field.

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
@ratulsarna
ratulsarna deleted the fix/bb-cli-launcher-loop branch October 30, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Script automations that call bb spawn bb endlessly until the server runs out of memory

2 participants