Skip to content

Commit 593440d

Browse files
fix(vcs): give git worktree add a longer timeout on large repos
Every git command runs under DEFAULT_TIMEOUT_MS (30s). `git worktree add` checks out the full tree, so on large repositories it legitimately takes longer than that — e.g. a repo with ~375k files takes ~40s on an idle machine (measured: `worktree add --no-checkout` is ~0.05s, writing the files is the cost). The result is that creating a new worktree fails deterministically with "Git command timed out", which surfaces as every new-chat worktree spawn erroring out in that project. Give createWorktree a dedicated 5-minute timeout. This keeps a bound on a genuinely hung git while allowing large-but-healthy checkouts to finish. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent e321667 commit 593440d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎apps/server/src/vcs/GitVcsDriverCore.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ import {
3939
import { ServerConfig } from "../config.ts";
4040

4141
const DEFAULT_TIMEOUT_MS = 30_000;
42+
// `git worktree add` checks out the full tree, so on large repositories it can
43+
// take well beyond the default 30s (e.g. a 375k-file repo takes ~40s on an idle
44+
// machine). Give it generous headroom while still bounding a genuinely hung git.
45+
const WORKTREE_ADD_TIMEOUT_MS = 300_000;
4246
const DEFAULT_MAX_OUTPUT_BYTES = 1_000_000;
4347
const OUTPUT_TRUNCATED_MARKER = "\n\n[truncated]";
4448
const PREPARED_COMMIT_PATCH_MAX_OUTPUT_BYTES = 49_000;
@@ -2761,6 +2765,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
27612765

27622766
yield* executeGit("GitVcsDriver.createWorktree", input.cwd, args, {
27632767
fallbackErrorDetail: "git worktree add failed",
2768+
timeoutMs: WORKTREE_ADD_TIMEOUT_MS,
27642769
});
27652770

27662771
if (input.newRefName && input.baseRefName) {

0 commit comments

Comments
 (0)