Skip to content

bug: menubar 0.9.20 refresh livelock — fixed 45s kill + leaked refresh lock + waiter gives up before stale gate #1117

Closed

Description

@iamtoruk

Field report (founder's machine, 21k-file corpus, confirmed live): the 0.9.20 menubar never completed a single payload fetch after upgrade. Children spawned every ~50-60s, each killed at exactly 45s with ~1.2s CPU (blocked on the refresh lock, not parsing). 0.9.18/0.9.19 were fine.

Chain of causes (diagnosed with live evidence)

  1. Tripwire: CACHE_VERSION 5→7 in 0.9.20 (sessions: attribute PR spend per turn instead of per session #790/sessions: fold subagent runs into PR attribution #791) invalidates the whole session cache → full rehydration (>45s on large corpora).
  2. Fixed kill: mac/Sources/CodeBurnMenubar/Data/DataClient.swift spawnTimeoutSeconds = 45, SIGTERM→SIGKILL +0.5s — kills the rehydrating child mid-transaction.
  3. Lock leak: src/cache-refresh-lock.ts has no signal cleanup (unlike session-cache's hydrating.lock), so the killed holder leaves session-refresh.lock owned by a dead pid.
  4. Livelock: DEFAULT_WAIT_MS = 30_000 < DEFAULT_STALE_MS = 90_000 — a waiter always gives up before it may steal an abandoned lock. Every next spawn burns 30s waiting, has ~15s left, dies; a takeover winner is killed mid-refresh, minting a fresh stale lock. Observed: lock rotating through a series of dead menubar pids.

Contributing: the resident serve child dies at its fixed 60s warm-up on large corpora and ensureStarted() has no re-entry — serve stays dead for the app's lifetime; 4 orphaned serve --stdio processes (ppid 1) found, so the stdin-close-kills-child invariant does not hold. Combined scope puts a 3s-connect/15s-per-peer device fetch on the badge path (latent; measured 47s with peer down).

Fix plan (all-users)

The merged perf stack (#1097 partial saves, #1105/#1108/#1109) already shrinks the window, but without A-D the livelock recurs on any corpus where one refresh crosses the ceiling (e.g. every future cache bump).

Activity

  1. added a commit that references this issue on Aug 24, 2026
    272da80
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions