fix(git): time out hung worktree-creation git processes#3054
Merged
Conversation
`git worktree add` and the post-checkout hook were spawned with no timeout, so a wedged git process (lock wait, credential prompt, slow network smudge, a hanging hook) would hang worktree creation forever — the task never leaves its pending state and the user's prompt is stranded. Bound both spawns: on timeout, SIGTERM the process, escalate to SIGKILL after a grace period, and reject/return a timeout error. The rejection propagates through createWorkspace, whose finally clears the dedup-map entry, so a retry isn't stuck awaiting the dead promise either. - git worktree add: 120s - post-checkout hook: 300s (installs can be legitimately slow) Generated-By: PostHog Code Task-Id: bb024b86-4ac5-4ec6-87af-3d8809d28466
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
|
Reviews (1): Last reviewed commit: "fix(git): time out and kill hung worktre..." | Re-trigger Greptile |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
frankh
approved these changes
Jul 1, 2026
tatoalo
approved these changes
Jul 1, 2026
The worktree test referenced KILL_GRACE_MS but it was module-private in worktree.ts, causing a TS2304 "Cannot find name" error. Export the constant and import it in the test. Generated-By: PostHog Code Task-Id: 6fc04ebf-82c4-44cb-a06c-4d4d37c6de14
frankh
added a commit
that referenced
this pull request
Jul 1, 2026
#3054 added kill-timeouts to `git worktree add` and the post-checkout hook, and #3053 restructured the saga to clear the provisioning spinner and keep the task for retry when provisioning fails. Both landed on main and supersede the worktree-add/hook-timeout and spinner-clearing parts of this PR, so those are dropped here. The one hang path neither covered is the `git fetch` that precedes worktree creation — the trigger both fixes cited. It still runs unbounded inside the per-repo write lock, so a blocked fetch (network stall, unreachable remote) never settles, the lock is never released, and every later worktree creation for that repo queues behind it forever. Bound the two fetch call sites (resolveFreshBaseRef and createWorktreeForRemoteBranch) with a timeout. The fetch runs through simple-git rather than a raw spawn, so it can't use armProcessTimeout; instead it aborts via the AbortSignal executeWrite already forwards to its scoped git client, which kills the fetch subprocess and releases the write lock. On timeout the trunk path degrades to the local ref and the remote-branch path fails with a retryable error, rather than hanging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a 2 min timeout to
git worktree addand 5 min timeout to the post-checkout hook.On failure, the prompt is recovered with the changes made in #3053
Created with PostHog Code