Skip to content

Stale/unresolvable git worktree gitdir pointer triggers unbounded repos:changed + git-worktree reconcile storm (~25/sec) #5381

Closed as not planned

Description

@davideiffert

Operating system: macOS 26.2 (Apple Silicon)
Orca version: 1.4.68

Short summary

A single stale/unresolvable git worktree pointer sends Orca's repo/worktree reconcile path into an unbounded loop: repos:changed broadcasts at ~25/sec and git worktree subprocesses spawn at ~10/sec, indefinitely. Each repos:changed drives a renderer fetchRepos() and re-derives downstream state, so the whole app churns (constant re-renders + CPU/battery burn). Orca should detect that a worktree's gitdir is missing and fail that worktree gracefully instead of spinning.

How it happens

A worktree's .git file contains gitdir: <path>. If the main repo directory is renamed/moved (very common), that path goes stale and no longer exists. In my case the repo dir was renamed drafthouse → drafthouse-internal, leaving a worktree pointer at:

gitdir: /Users/mack/apps/drafthouse/.git/worktrees/cursive-blob   # missing

git worktree list from the main repo still looks fine, but operations from that worktree (e.g. git:upstreamStatus) fail with fatal: not a git repository, and the reconcile loop never converges.

Evidence (measured live via DevTools console)

  • window.api.repos.onChanged fired 256 times in 10 s (~25/sec); worktrees:changed fired 0 — so it's repo-level reconcile, not file-change driven.
  • Trace log (main.trace.ndjson): 866 git.exec spans in 82.9 s (~10.4/sec), of which 819 were git worktree, split across the two local repos.
  • Visible symptom: the sidebar "Live Ports" plug icon (WorktreeCardPortsTrigger) flickers near-constantly. It's driven by WorkspacePortScanner, whose effect calls setWorkspacePortScan(null) on every re-run; the constant repos:changed → new repos identity → scanTargets/refresh identity change re-runs that effect, wiping the shared scan state. DOM probe: plug present only ~21–34% of samples, all plugs blinking in lockstep (shared-state wipe, not per-port).

Reproduction

  1. git worktree add ../wt-demo in some repo; add the repo to Orca so the worktree shows in the sidebar.
  2. Break the pointer the way a rename would: rename the main repo dir (mv repo repo2) so the worktree's gitdir: target no longer exists. (Re-add/keep it visible in Orca.)
  3. Observe: git worktree subprocesses and repos:changed events fire continuously; CPU stays elevated; any worktree with a detected listening port shows a flickering ports plug.

Workaround (also the confirming fix)

cd <main-worktree> && git worktree repair — re-points the stale gitdir. The storm stopped immediately and CPU dropped.

Suggested fix

When a worktree's gitdir is unresolvable, mark that worktree unavailable and skip/back off rather than re-broadcasting repos:changed and re-running git worktree on a tight loop. (Bonus: WorkspacePortScanner shouldn't clear the shared scan to null on every effect re-run — keep last-good results so a transient re-run doesn't blank the UI.)

I traced the symptoms, trigger, and repro but did not pin the exact reconcile loop in orca-runtime; happy to dig further if useful.

Activity

  1. davideiffert commented on Jun 15, 2026

    @davideiffert
    ContributorAuthor

    Closing this — my original diagnosis was wrong.

    On further investigation, the stale worktree gitdir pointer is not the cause. After repairing the pointer (git worktree repair), the same repos:changed + git worktree storm recurred — in fact it intensified on v1.4.70 (~40 git worktree list/sec across repos), with the pointer healthy and no file changes triggering it. So this looks like a runaway poll/feedback loop independent of any pointer state, not the stale-pointer scenario I described.

    The underlying problem (an unbounded worktree-reconcile loop driving constant repos:changed) does appear real and worth fixing, but I'd rather pin the exact trigger before reporting than leave an inaccurate issue open. I'll open a fresh, properly-scoped issue once I have it nailed down. Apologies for the noise.

  2. added theissue type on Jul 12, 2026
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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions