Repository navigation
Description
Summary
After a crash leaves one thread in status starting (with a ready environment), the bb server can never start again: every boot exits with code 0 before it listens and before its logger writes anything. The supervisor retries forever ("Server failed to restart"). Expected: the 30 s provider-settle timeout fires and startup continues.
Versions and environment
- bb 0.44.0 desktop app (bundled server), macOS 26.6.2, Apple Silicon. Same result with the 0.45.0 bundle (
desktop-v0.45.0). - Code is unchanged on
mainat 09ff18a. - Data dir
~/.bb, default ports. The thread that triggered it was an ultragoal plugin worker thread.
Steps to reproduce
- Have a thread with
status = 'starting',deleted_at IS NULL, and an environment that is ready (here: left behind when the server crash-looped mid-provisioning). - Start the server:
ELECTRON_RUN_AS_NODE=1 /Applications/bb.app/Contents/MacOS/bb /Applications/bb.app/Contents/Resources/app.asar.unpacked/node_modules/bb-app/server/dist/index.jswithBB_DATA_DIRpointing at that data dir. - It exits with code 0 within ~0.4 s and prints nothing, even with
BB_LOG_LEVEL=traceand--trace-exit.
Did not reproduce with an empty data dir: the same binary listens in ~2 s.
Expected vs actual
Expected: startup recovery sweep waits ≤30 s for provider registrations, then the server listens.
Actual: process exits 0 after ~380 ms, before "Server listening"; server-stdio.log stays empty;
bb-app logs "Server failed to restart" in a loop (17k times in one day here).
Evidence
Mechanism (permalinks at main 09ff18a):
- The pre-listen sweep runs and is awaited: start-server.ts#L351. The listener starts after it (#L363), and plugins start after the listener (#L390).
markRegistrationsSettled()is only called fromstartServerPlugins().finally()(#L96), because the registry is created withdeferRegistrationsSettled: true(#L164). - The sweep picks up
startingthreads (periodic-sweeps.ts#L318) →advanceThreadProvisioning→requestThreadStart→buildThreadStartCommand, which awaitsproviderRegistry.whenRegistrationsSettled()(thread-commands.ts#L268). - The only fallback is a 30 s timer that is unref'd (provider-registry.ts#L188-L189). Before listen nothing else holds the event loop (better-sqlite3 is synchronous), so Node drains the loop and exits 0 with the promise still pending.
How it was measured:
- An
async_hooksdump atbeforeExit(with--enable-source-maps) shows 37 pending promises. The deepest frames arebuildThreadStartCommand (thread-commands.ts:268)←startThreadIfEnvironmentReady←runThreadProvisioningOrphanCleanupSweep←runStartupRecoverySweep←runServer (start-server.ts:322). - Preloading a referenced timer (
bb --require hold.cjs …/server/dist/index.js, wherehold.cjsissetTimeout(() => {}, 90_000)) is enough on its own to fix it. The server listens at t=31 s, the sweep marks the threaderror, and the next plain boot listens in 1 s.
What you ruled out
- Not DB corruption:
PRAGMA quick_check=ok, and the migration hashes match a fresh 0.44.0 DB (132/132). - Not a server-move lock:
bb server unlock --json→unlocked: false. - Not the bundle: codesign verifies, and an empty data dir boots.
- Not fixed in 0.45.0: the same clone exits the same way with the 0.45.0 server.
- Not sidebar-bootstrap returns 409 no_provider_available during startup: read-only project listing does not await whenRegistrationsSettled #3207: that one is about read-only project listing during startup; this one is the startup sweep hard-blocking listen.
NODE_OPTIONScannot be used as a workaround: this Electron build ignores Node env vars ("Node.js environment variables are disabled because this process is invoked by other apps").
Suggested priority and effort (optional)
High: one crash at the wrong moment makes BB unbootable with no error message, and the only workaround is the external preload above (or hand-editing bb.db). Effort is probably low: don't await whenRegistrationsSettled() from the pre-listen sweep (defer provisioning starts until plugins have settled), or keep the 30 s fallback timer referenced.
AGENT GENERATED (Claude Code session diagnosing a local BB outage on 2026-10-04; evidence above is from that session).
Activity
bb-slop-cop commentedon Oct 4, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilothost,providers.confirmed-repro.Keep provider startup fallback timer alive (get-bb#4864)