Skip to content

on large checkout drops runtime connection after creating git worktree (orphan leak) #20108

Closed

Description

@aigentic-net

Summary

orca worktree create against a large repo checkout (~700MB, includes node_modules) fails with runtime_unavailable ("The Orca runtime closed the connection before responding") — but the git worktree has already been created by the time the connection drops, so every attempt leaks an orphan worktree that must be cleaned up by hand.

Repro

orca worktree create --repo id:<repo> --name <name> --no-parent --setup skip --json
# => {"ok": false, "error": {"code": "runtime_unavailable", "message": "The Orca runtime closed the connection before responding. Restart Orca and try again."}}
git worktree list  # the new worktree IS present despite the error

Same command against a small repo (760KB) on the same host, same daemon, same runtime succeeds. worktree list, worktree current, terminal create, and orchestration dispatches all work normally throughout — only create-on-large-checkout drops.

Environment

  • Orca 1.4.200, daemon protocol v36, macOS arm64, local runtime (ready/reachable before and after)
  • Large repo: ~702MB working copy with node_modules; small repo: 760KB

Expected

Either the create completes, or it fails atomically (no git worktree left behind), or it fails with a specific error (timeout/scan budget) instead of a generic connection drop.

Actual

  • Connection drops mid-create, deterministically reproducible on the large repo.
  • Orphan worktrees accumulate across retries; each removes cleanly afterwards with orca worktree rm --force, so removal paths are fine — only create is affected.

Impact on automation

CLI/automation callers cannot distinguish this from a total failure and will retry, accumulating orphans. A bounded create with either atomic rollback or a distinct error code would let callers handle it safely.

Activity

  1. aigentic-net commented on Sep 11, 2026

    @aigentic-net
    Author

    Related prior art from the mirror: 1268fb5 (#17388, Aug 30) fixed the variant where create verification failed against a softened listing failure. This report is the cousin that fix didn't cover — git confirms AND lists the worktree fine (plain git worktree list shows it immediately); what dies is the daemon connection itself, mid-create, deterministically on a ~700MB checkout while a 760KB repo on the same daemon succeeds. Smells like a post-create step (scan/index) exceeding a response budget rather than a git failure.

  2. AmethystLiang commented on Sep 16, 2026

    @AmethystLiang
    Contributor

    Thanks for reporting! We'll look into preventing worktree leaks when creation times out on large repositories.

  3. added
    bug
    on Sep 19, 2026
  4. added theissue type on Sep 19, 2026
  5. cderv commented on Sep 28, 2026

    @cderv

    I can reproduce this on Windows 11 with Orca 1.4.215, native CLI, on a ~720 MiB repo (~7.4k tracked files). The worktree, branch, comment/linked issue and agent terminal are all created, only the CLI response is lost.

    Timeline for a stripped-down call (--setup skip, no --agent, no --prompt):

    • 09:19:07Z CLI starts worktree create --base-branch upstream/main --setup skip --no-parent --json
    • 09:19:40Z CLI exits 1 with runtime_unavailable ("closed the connection before responding"), 33.4s after start
    • 09:19:40Z git creates the branch (branch reflog)
    • ~09:20:50Z git releases the initializing lock on the new worktree

    The daemon PID and runtime id are the same before and after, so the runtime did not restart. With --setup run --agent claude --prompt ... the result is the same; the agent terminal is created after the CLI has already failed.

    From what I can tell, this looks like the 30s idle timeout on the runtime socket (named pipe on Windows) closing the connection while worktree.create is still running, since only long-poll methods arm keepalive:

    socket.setTimeout(RUNTIME_RPC_SOCKET_IDLE_TIMEOUT_MS, () => {
    socket.destroy()
    })

    If that's right, #22347 would cover this on Windows too, as the named-pipe path uses the same transport. Please correct me if I'm reading it wrong. Happy to test a build on Windows.

    Related: #7410

  6. jentor commented on Oct 2, 2026

    @jentor

    Observed the same ambiguous-create failure on macOS arm64 with Orca 1.4.217, then 1.4.218 (build 95e8725, daemon protocol 37).

    The invoking agent reported two worktree create --repo id:<repo> --name <name> --no-parent --agent codex --prompt <redacted> calls ending in runtime_unavailable / connection closed, and initially saw no worktree. A receiving agent subsequently verified both git worktree list --porcelain and orca worktree list --json: the requested worktree did exist, and its Codex terminal was already actively processing the prompt. A fallback agent in the main checkout was running the same task. We stopped the duplicate before either performed writes.

    Local trace evidence: a git.exec worktree operation with 7 arguments started at Unix timestamp 1790973888.258 and ran for 32,291 ms. Worktree-local configuration operations followed at 1790973920.549 and 1790973920.576. CLI-created metadata retained createdAt=1790973704446; the eventual worktree creation timestamp was 1790973920629. Runtime was ready/reachable when inspected afterwards; terminal create, list and read worked.

    Additional bounded trace evidence from the same create window: git fetch took 60,032 ms and ended with GitCommandTimeoutError; subsequent git status and git reset spans took 61,100 ms and 61,160 ms respectively and succeeded. The final worktree operation then took 32,291 ms. This narrows the observed delay to Git operations but does not establish why the CLI socket closed.

    This confirms delayed successful creation/agent startup after an apparent failure, rather than a reliable rollback. I have not independently proved the internal timeout cause; the outstanding #22347 looks relevant. Please include agent-launch/prompt delivery reconciliation in the fix so a caller can recover the original operation without starting a second owner. No private repository paths, task prompt, credentials or raw logs are attached.

  7. AmoabaKelvin commented on Nov 17, 2026

    @AmoabaKelvin
    Collaborator

    Fixed by #29262: the runtime connection stays open while a slow worktree create is still running.

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

    bug

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions