Repository navigation
Description
Summary
If a machine is still in setup when the bb server restarts, the server does not become healthy within the launcher's 60 s limit, so the start fails. A machine provider whose setup is waiting on the user, such as Manual machine setup waiting for its enrollment command, is still pending at the next start, so every restart fails the same way until the record is cleared. Expected: the server starts and listens, and the pending machine setup continues in the background.
Versions and environment
- Reproduced on
mainat 9f72ff5aeb withpnpm start:worktree, a fresh data dir, Node 22.19.0, Linux (Fedora 44). - First seen while testing a fork prototype for feat: enroll SSH sandboxes without a manual installer #3666, on a dev instance with a Manual machine setup left pending by a page reload: 8 starts in a row failed, and the server was healthy 1 s after that record was cleared.
- Installed bb on the reporting machine: 0.50.1.
Steps to reproduce
pnpm start:worktreeon a fresh checkout of main. It prints the server URL, herehttp://127.0.0.1:22551.- With the checkout's CLI (
pnpm -s bb:dev,BB_SERVER_URLset to that URL), add a direct route so Manual setup does not need a getbb.app sign-in, then create a Manual machine and do not run its enrollment command:pnpm -s bb:dev server access add direct http://<lan-ip>:22551 pnpm -s bb:dev server access order direct pnpm -s bb:dev machine create --provider manual --no-wait --json # lifecycle.phase: "creating"
- Stop the instance and run
pnpm start:worktreeagain.
Control: set that host row to phase='destroyed' and start again.
Expected vs actual
With the pending machine (timestamps added):
08:29:14 ○ Starting server
08:30:14 ✗ Server failed to start
08:30:14 Server failed to become healthy: Timed out waiting for health at http://127.0.0.1:22551/health
Control, without it:
08:30:44 ○ Starting server
08:30:45 ✓ Server listening on http://127.0.0.1:22551
Expected: the server listens within a few seconds in both cases.
Evidence
From the code at 9f72ff5. I observed the 60 s failure, not the internal timing:
- The startup recovery sweep is awaited before the HTTP listener starts:
start-server.ts#L506runs before#L518. - One of its steps is the machine lifecycle sweep:
periodic-sweeps.ts#L913. - For a host in
creating, that sweep awaits the whole create:provider-orchestration.ts#L1385-L1387. Manual setup's create waits for the enrollment connection:manual-provider.ts#L39. - The sweep item stops waiting only after
ITEM_DETACH_AFTER_MS = 60_000:item-sweep.ts#L15, raced at#L255. - The launcher's health limit is also 60 s:
launcher.ts#L149. The desktop app hasSTARTUP_TIMEOUT_MS = 60_000:types.ts#L8.
So the server cannot listen before the launcher gives up. The failed run wrote no server log lines before it was stopped.
The same path applies to any machine provider whose create can take more than about 60 s after a restart, for example an SSH setup that is still installing.
What you ruled out
- Not Server never starts: pre-listen startup sweep awaits provider registrations whose 30 s fallback timer is unref'd, so the process exits 0 #4862: that was an unref'd provider-registration timer that let the process exit 0 before listening, and it was fixed in Keep provider startup fallback timer alive #4864. Here the process keeps running and the launcher times out.
- Not the environment: the same instance and data dir start in 1 s once the pending host row is cleared.
- Not Connect: the reproduction uses a direct route.
Suggested priority and effort
High: a single abandoned Manual setup blocks every later start, and the only workaround is editing bb.db. The fix needs one decision: should startup wait for machine provider recovery at all? One option is to run the machine lifecycle step after the listener starts, or not to await creates still in progress during the startup sweep.
AGENT GENERATED
Activity
bb-slop-cop commentedon Nov 25, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilothost.confirmed-repro.apps/server/test/services/startup-machine-recovery.test.tsfails before the fix and passes afterward; all 49 tests across seven relevant suites, server typechecking, and type-aware lint pass.Keep machine recovery off the HTTP readiness path (get-bb#8200)