Repository navigation
Keep machine recovery off the HTTP readiness path - #8200
Merged
Merged
Conversation
SawyerHood
added a commit
that referenced
this pull request
Nov 30, 2026
## What was wrong `pnpm start` failed every time with `Server failed to become healthy: Timed out waiting for health` after a bb process was killed while threads were being created. Startup awaits `runStartupRecoverySweep` before opening HTTP, and its `thread-orphan-cleanup` step ran the thread provisioning sweep inline. For each thread left in `starting`, `advanceThreadProvisioning` reaches `buildThreadStartCommand`, which awaits `providerRegistry.whenRegistrationsSettled()`. Provider plugins only register after the server listens (`startServerPlugins` runs after "Server listening"), so each such thread waits the full `REGISTRATIONS_SETTLED_TIMEOUT_MS` (30s). With three stuck threads, startup needs 90s+ and the launcher's 60s health deadline kills it, which leaves the same threads behind for the next attempt. Found on a real data dir with logpoints in the built server: every step up to `runStartupRecoverySweep` finished within a second; the sweep stopped in `thread-provisioning` → `requestThreadStart` → `buildThreadStartCommand` → `whenRegistrationsSettled`. ## What changed Same shape as #8200 (machine recovery): run only the thread provisioning step in the background through the existing error-handled `runStartupRecoveryStep`, and keep archived/deleted thread teardown awaited. The periodic sweep still runs provisioning then teardown in order. ## How I verified - New `test/services/startup-thread-provisioning.test.ts` holds a starting thread's provisioning open and asserts startup recovery still finishes. It fails without the fix (`startup must not wait for thread provisioning to finish: expected false to be true`) and passes with it. - `turbo run test --filter=@bb/server -- startup-thread-provisioning startup-machine-recovery periodic-sweeps item-sweep periodic-sweep-jobs thread-live-start-handoff environments/provider-orchestration` passes. - `turbo run typecheck lint --filter=@bb/server` passes. - The real data dir that hung starts once the patch is applied (see below).
scowalt
pushed a commit
to scowalt/bb
that referenced
this pull request
Dec 1, 2026
## What was wrong `pnpm start` failed every time with `Server failed to become healthy: Timed out waiting for health` after a bb process was killed while threads were being created. Startup awaits `runStartupRecoverySweep` before opening HTTP, and its `thread-orphan-cleanup` step ran the thread provisioning sweep inline. For each thread left in `starting`, `advanceThreadProvisioning` reaches `buildThreadStartCommand`, which awaits `providerRegistry.whenRegistrationsSettled()`. Provider plugins only register after the server listens (`startServerPlugins` runs after "Server listening"), so each such thread waits the full `REGISTRATIONS_SETTLED_TIMEOUT_MS` (30s). With three stuck threads, startup needs 90s+ and the launcher's 60s health deadline kills it, which leaves the same threads behind for the next attempt. Found on a real data dir with logpoints in the built server: every step up to `runStartupRecoverySweep` finished within a second; the sweep stopped in `thread-provisioning` → `requestThreadStart` → `buildThreadStartCommand` → `whenRegistrationsSettled`. ## What changed Same shape as get-bb#8200 (machine recovery): run only the thread provisioning step in the background through the existing error-handled `runStartupRecoveryStep`, and keep archived/deleted thread teardown awaited. The periodic sweep still runs provisioning then teardown in order. ## How I verified - New `test/services/startup-thread-provisioning.test.ts` holds a starting thread's provisioning open and asserts startup recovery still finishes. It fails without the fix (`startup must not wait for thread provisioning to finish: expected false to be true`) and passes with it. - `turbo run test --filter=@bb/server -- startup-thread-provisioning startup-machine-recovery periodic-sweeps item-sweep periodic-sweep-jobs thread-live-start-handoff environments/provider-orchestration` passes. - `turbo run typecheck lint --filter=@bb/server` passes. - The real data dir that hung starts once the patch is applied (see below).
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.
🚨 SLOP COP 🚨 ·
new-issue-autopilotHuman comments
What was wrong
Startup awaited the machine lifecycle recovery step before opening HTTP. A persisted machine still being created could hold that step until the item sweep detached after 60 seconds, exhausting the launcher's separate 60-second health deadline. The real Manual provider reproduces this while waiting for enrollment.
Verified report: https://get-bb.github.io/reports/issues/8199.html
What changed
Run only the machine recovery step in the background through the existing error-handled startup helper. Keep the preceding startup repairs awaited, and retain the existing machine-operation tracking, deduplication, failure handling, and periodic sweep completion behavior. Add a real-SQLite regression that proves startup completes while creation is pending and that creation subsequently reaches active.
Scope: 65 changed text lines (64 additions + 1 deletion), 2 files, one server recovery subsystem. No dependency, generated file, stored-data, public API, wire protocol, or security-boundary changes.
How you verified
85521e8a1aa64bf9a225eadd86210b83122e49f5:startup must not wait for machine setup to finish: expected false to be true.pnpm exec turbo run test --filter=@bb/server -- test/services/startup-machine-recovery.test.ts test/services/periodic-sweeps.test.ts test/system/item-sweep.test.ts test/system/periodic-sweep-jobs.test.ts test/services/machines/provider-orchestration.test.ts test/services/machines/lifecycle-recovery.test.ts test/threads/machine-lifecycle.test.ts— 7 files, 49 tests passed.pnpm exec turbo run typecheck lint lint:type-aware --filter=@bb/server— passed; type-aware lint reports zero warnings/errors.git diff --check— passed. The new test is formatted; an existing formatter-only union-type reflow elsewhere in the production file is intentionally excluded.Fixes #8199