Skip to content

fix(worktrees): allow four minutes for checkout - #1071

Merged
nixuuu merged 1 commit into
devfrom
feat/worktree-checkout-timeout
Nov 21, 2026
Merged

nixuuu merged 1 commit into
devfrom
feat/worktree-checkout-timeout

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Changes

  • Allow 240 seconds for git worktree add after Git starts. The report showed 22,067 of 56,756 files written when the 60-second limit expired on Windows. At that rate, checkout would take roughly 154 seconds. Four minutes leaves room for variations in file sizes and write speed.
  • Give the worker up to 35 seconds to start checkout, including repository and process queues and the optional fetch. Reserve 40 seconds for termination, verification, rollback and delivery within the 315-second gateway wait. Use the same worker path for creation, continuation and spawn_thread. Mixed-version gateway and worker pairs retain the 60-second checkout and 90-second gateway wait.
  • Align web/desktop, native mobile, draft delivery and linked gateway deadlines for creation that may need checkout. The Claude agent bus has a 330-second deadline.

Verification

  • Verified PR head fa8819fa on nix-pc (Linux, Git 2.56.0, Bun 1.4.5). The 92-second checkout completed via gRPC and started a usable thread. The same test verified that an expired queued request returned promptly and created no branch. The worktree and spawn_thread integration suites also covered normal checkout and cleanup after a real process timeout.
  • Ran the production checkout path with a blocked Git hook. The old and new timers stopped Git after 60.71 and 240.21 seconds. Both runs removed the checkout, Git registration and branch. Targeted check:tmp covered 58 cases with no temp leaks. An existing continuation test reached its 5-second test harness limit under load and passed in the isolated continuation run with a 20-second harness limit. Gateway, worker, web and mobile typechecks, edited-file lint, and diff checks passed.
  • The native mobile integration tests passed on nix-pc. They exercised the app’s creation stream, unary fallback, and draft recovery over Connect through a real gateway and worker. The device tool could not establish ownership of the Android runtime, so no in-app device test was possible.
  • The Windows CI job runs a slow Git checkout, verifies it unlocks, and tests cleanup using real Git for Windows worktree metadata and a staged incomplete checkout. A live timeout of a Windows process tree and a reproduction on the reported Windows 11 repository are unverified.
  • Copy audit (§8). The preparation deadline adds a short reason and retry action. The checkout timeout keeps its existing wording. Both messages contain no paths or variable labels.

Thanks to @janek-normalnie for reproducing the timeout and sharing the file counts and Git version.

Related: #915, #1026

Keep the extended checkout budget within the worker query and thread creation deadlines, including preparation and rollback. Negotiate support with the worker before extending the query.

Related: #915, #1026
@nixuuu
nixuuu marked this pull request as ready for review November 21, 2026 12:01
@nixuuu
nixuuu enabled auto-merge (squash) November 21, 2026 12:01
@nixuuu
nixuuu merged commit a25da4e into dev Nov 21, 2026
18 checks passed
@nixuuu
nixuuu deleted the feat/worktree-checkout-timeout branch November 21, 2026 12:06
nixuuu added a commit that referenced this pull request Nov 21, 2026
## What changed

- Show the effective checkout limit and the measured time when the Git
timeout triggers. The measurement ends when Canopy requests
interruption, before it waits for process exit or starts cleanup.
- Carry the detail through the existing thread preparation errors and
`spawn_thread`. The gateway accepts only the fixed timeout wording and
numeric durations for `spawn_thread`. Unmeasured timeouts, output
limits, other Git errors and worker RPC deadlines keep their existing
messages.
- The checkout limit policy and cleanup logic stay as before.

Thanks @janek-normalnie for reporting the interrupted Windows checkout
and suggesting both values.

Related: #982

## Verification

- Local on nix-pc after rebasing onto #1071, at
`86fa1f0685dedbc1871251fb1d70ebdc923ba288`: 53 tests passed with
`check:tmp` across process governor, worktree creation failures,
worktree automation, thread creation progress and worktrees. This covers
1.5 s and 3.5 s limits, a deliberately delayed timeout callback, a real
checkout timeout through the worker link to the UI stream, saved failure
and `spawn_thread`, redaction and distinct failure messages, and a
successful checkout past the old 90-second worker deadline.
- Integration test typecheck, lint and formatting of edited TypeScript,
and the Git diff check passed.
- Chromium, before the rebase: started a new worktree in an isolated dev
stack and confirmed both values under **Show details**. Checked short,
typical and long durations at 390 and 800 px in both themes, plus the
actual flow at desktop width. The existing composer intercepted a
pointer click at 1280 × 577. Keyboard activation opened the disclosure.
- Native mobile receives the same failure through
`CreateThreadWithProgress` and renders its detail in **Show details**.
Verified the stream and traced the native code path. Manual Android
verification was unavailable because device automation could not
establish ownership of the emulator.
- GitHub CI owns the full gate.

## Copy audit

“Git exceeded its time limit.” → “Git timed out after 60.012 s while
creating the worktree. The limit was 60 s.” Two short sentences name the
operation and the limit. The existing failure instructions and **Return
to draft** action stay available. The detail uses the existing
disclosure, worktree terminology and spaced time units. All durations
wrap in the checked widths, and no meaning depends on color or icons.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant