Skip to content

Deleted thread's worktree environment stays in 'retiring' past its retire time; teardown starts only after bb environment delete #7193

Closed

Description

@apshendev

bb 0.48.1, Windows 11 host connected via bb Connect, git-worktree provider, repository with a .bb-env-teardown.sh hook.

Steps. Create a thread in a new worktree environment (bb thread create --new-environment worktree), let it go idle, then bb thread delete <id> --yes.

Expected. The environment is torn down shortly after the thread is deleted: the teardown hook runs and the worktree directory is removed.

Actual. After about 15 minutes the worktree directory still existed and no teardown hook process was running. bb environment show reported:

Status: ready
Lifecycle: retiring
Retire at: 2026-11-06T18:12:59.225Z
Created: 06.11.2026, 18:59:28
Updated: 06.11.2026, 19:07:59

The Retire at time was already in the past (date -u on the host showed 20:12 UTC). Running bb environment delete <env-id> immediately switched it to Lifecycle: teardown; the hook ran, finished successfully and the worktree was removed.

In the same session, two other worktree environments of the same project were torn down right after bb thread delete, so this does not happen every time.

This differs from #4158: there the teardown hook was interrupted and the environment is stuck in teardown failed with endless retries. Here the teardown never started at all, and the environment sat in ready / retiring past its Retire at time.

We have not checked whether clock skew between the host and the server is involved.

Activity

  1. added theissue type on Nov 6, 2026
  2. added
    workspaces
    confirmed-repro
    on Nov 6, 2026
  3. bb-slop-cop commented on Nov 6, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Medium · Labels: workspaces, confirmed-repro.
    • Reproduction report: REPRODUCED, confidence medium. Repeated on trusted main in two clean checkouts; explicit cleanup also succeeds while automatic retirement is stalled.
    • Root cause: the periodic lifecycle job awaits all removals, so a slow removal prevents later ticks from checking newly expired environments on other hosts. The server/SQLite reproduction is verified; the original Windows/Connect trigger and clock relationship remain unverified.
    • Fix: ready PR Keep retirement sweeps moving during slow environment removals #7194 dispatches periodic cleanup without waiting for slow removals, preserving existing concurrency protections. The regression fails before and passes after; 187 relevant tests, server typecheck, and diff checks pass. 86 changed lines across 3 files.

    AGENT GENERATED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reproworkspaces

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions