Repository navigation
Description
Environment. bb 0.43.3 desktop; git-worktree provider; repositories with a
.bb-env-teardown.sh hook.
Symptom. After a host-daemon restart interrupts a teardown hook, the environment stays in
status: error, lifecycle.teardown.status: failed with the message
Environment hook outcome is unknown after interruption. Automatic cleanup is blocked; inspect the workspace before recovering it.
and is retried once per minute indefinitely. On one host 18 environments are in this state with
attempt counters between 2,981 and 8,305 (about 5.8 days at one attempt per minute), each attempt
costing a host RPC with a 6 s timeout; 10 of their worktrees still exist (7.6 GB) and 8 are
already gone, yet none can complete. bb guide environments documents that a lost hook blocks
cleanup and "requires inspection before recovery", but there is no recovery verb, no filter to
find such environments, and no bound on the retries.
Evidence (installed bundle server/dist/start-server.js).
cancelPendingEnvironmentHook(209864–209884): if theenvironment_hook_operationsrow has no
finished_at, it sendsenvironment.hook.cancelwithTRANSPORT_GRACE_MS(6 s, 209894); when the
host answersunknownit throws the message above before thefinished_atupdate that
follows, so the row stays pending.runEnvironmentHook'scatchawaits that cancel before logging "continuing removal"
(209849–209857), so the throw escapes torunRemove.runRemove(239037–239110) catches it and writesteardownStatus: "failed",
retireAt: Date.now() + REMOVE_RETRY_MS(60 s, 239905). The lifecycle sweep re-enters as soon as
retireAtpasses (239186–239187), incrementsteardownAttempt(239189) and takes the identical
path. No backoff, no cap, no terminal state.- Recovery: no route or CLI clears
teardown_statusfor an environment; the only reset is the
provisioning upsert (34561), which is not reachable as an operation.bb environment delete
enters the same removal path.
Query to find affected rows. SELECT count(*) FROM environment_hook_operations WHERE finished_at IS NULL;
and SELECT id, teardown_attempt FROM environments WHERE teardown_status = 'failed';
Reproduction. Commit a .bb-env-teardown.sh that sleeps for a minute, archive the last thread
of a worktree environment, and restart the host daemon while the hook is running. The environment
enters teardown failed and retries every 60 s from then on.
Proposed fix.
- On the
unknownbranch, mark the hook operation finished with anunknownerror (and record
the message on the environment) so the next attempt can proceed toprovider.remove; the
guide already states there is no cross-restart process tracking, so the row cannot be resolved
later anyway. - Exponential backoff on the retry interval and a cap on
teardownAttempt, after which the
environment enters a terminalteardown: blockedstate that stops the RPCs. bb environment recover <id>(clear the teardown state after confirming no live threads; treat
a missing path as removed) andbb environment list --teardown failed.- Docs: state the retry cadence (currently 60 s, no backoff) and the recovery procedure next to
the existing sentence about the unknown-outcome block.
Filed from an audit of bb 0.43.3 by the Factory plugin (github.com/mattwyckhouse/bb-plugin-factory). Method, re-derived numbers and the adversarial review of this report: plans/076-host-sustainable-line/bb-core-issues/REVIEW.md in that repository.
Activity
bb-slop-cop commentedon Sep 23, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotClassified as Bug · Medium priority · High effort; applied
workspacesandconfirmed-repro.REPRODUCED · high root-cause confidence. Report and regression test. Two clean checkouts reproduced four failed teardown attempts, each rescheduled after 60 seconds, with the hook unfinished and zero provider-removal calls. The nine existing daemon hook tests passed.
Unknown hook cancellation throws before finishing its operation; the removal catch then schedules the same unresolved operation again. The test models daemon memory loss; reporter fleet counts and disk usage were not verified.
environment list --status errorprovides a broad filter.No PR: safe recovery requires a product decision about unresolved hook processes, outside the simple-fix limits.
RichieGP commentedon Sep 27, 2026
Hitting the same class of bug, slightly different trigger: a
manual-provider machine whose physical hardware was permanently decommissioned (replaced, wiped, never coming back online).bb machine remove <id> --yesaccepts the request, machine enterslifecycle.phase: "removing"withteardown: {"status":"failed","attempt":0}.bb machine retry-cleanup <id>returns success ("cleanup retried") butattemptnever increments past 0 and status stays"failed"— tried multiple times over several minutes, no change.bb machine reconcile <id>→409: Machine provider "manual" does not support suspend and resume.bb machine reconnect <id>as a possible escape hatch (since it can adopt the host ID from different hardware per #<PR 4209>) →409: Only active machines other than the server's own can be reconnected. So once a manual machine is inremoving, reconnect is blocked too — no path back toactiveto retry reconnect, and no path forward to complete teardown. Dead end either direction.No CLI/API force-delete exists for this state, matching what's described here. The machine just sits in
bb machine listforever as a disconnected zombie entry. Would like either:manualmachine's record when its host is known to be gone for good (skip teardown entirely, sincemanualmachines have no cloud resource to tear down anyway), orbb machine reconnectto be allowed against aremoving-phase machine so a live daemon (even on different hardware) can pick up the ID and let teardown complete normally.thelaggingway commentedon Oct 4, 2026
Still reproduces on bb-app 0.45.0 (server + host daemon), on a remote Linux machine
(Ubuntu 24.04) enrolled through a machine-provider plugin, git-worktree environments, repository
without a
.bb-env-teardown.sh.Additional observations:
bb machine removeputs the host in phaseremovingandwaits for these environments; it never completes. If the machine is offline (stopped or deleted),
the message becomes
Host is not connected, and there is again no way out: no--forceonmachine remove, andbb machine retry-cleanuprepeats the same path.bb environment cleanup <id>returnsokbut changes nothing (attempts kept rising 8 → 14).bb thread unarchivedoesn't reset the lifecycle either.host daemon) seconds later, while the teardowns were still pending.
Workaround that worked, for anyone stuck (back up
bb.dbfirst; server running is fine). For theaffected host only, do in one transaction what
markHostEnvironmentsDestroyeddoes, plus closethe pending hook rows:
Then
bb machine retry-cleanup <host>. Removal completed and the machine provider's remove ran.+1 to a supported recovery verb (e.g.
bb environment recover <id> --discard-hookand amachine-level
--forcefor offline/deleted machines), or bounding theunknownretries.cmcnamara87 commentedon Oct 29, 2026
macOS follow-up on bb-app 0.47.1, related to the recovery added for #5960 / #5961.
The interrupted-hook state still has no supported recovery path on our macOS host. The current CLI documents:
Our operator reports that
--recoverrefuses with “process inspection requires Linux”. A retained managed-worktree record independently shows the unknown-hook outcome / failed teardown state. We did not trigger another hook interruption or retry recovery merely to reproduce it.Operational impact, from the dated operator report: 32 archived, stuck worktrees were individually checked for clean source and pushed commits, then removed with ordinary
git worktree remove(no--force). Their BB records still report error/teardown. Dirty, unpushed, active or uncertain worktrees were retained. These are operator-reported counts, not a new fleet census by this comment.Please provide a supported macOS recovery guard and a supported reconciliation path for an already-absent, inspected worktree. Preserve the protection for live workspace users, detached hook processes and unreadable/ambiguous process state. A newer daemon instance, no terminal in BB, or a clean Git tree alone must not prove that no process uses the worktree. A bounded “Needs recovery” state is preferable to an indefinite retry loop.
We will not alter BB database rows, disable process checks, or use
--forceas a workaround. This report contains no user data, credentials, private repository paths or host identifiers.Agent-generated report, posted at the user's explicit request.
ymichael commentedon Nov 17, 2026
Fixed by #5961: teardown retries back off, stop after five attempts and show "Needs recovery", and
bb environment cleanup <id> --recoverfinishes the cleanup. #5859 addsbb machine remove --force. #7520 makes--recoverwork on macOS and ships in the next release. Closing.Give every persisted retry schedule one owner, an attempt cap and a n…