Fix worktree removal timing out on large install trees (#3902)
This commit is contained in:
1 parent
6319a97148
commit
f54ab901fa
2 files changed
+53
-1
No files matched your search
@@ -1517,6 +1517,51 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("allows worktree removal to run longer than the default command timeout", () =>
|
||||
Effect.gen(function* () {
|
||||
const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
const removalStarted = yield* Deferred.make<void>();
|
||||
const delayedRemovalSpawner = ChildProcessSpawner.make((command) =>
|
||||
Effect.gen(function* () {
|
||||
if (
|
||||
ChildProcess.isStandardCommand(command) &&
|
||||
command.args[0] === "worktree" &&
|
||||
command.args[1] === "remove"
|
||||
) {
|
||||
yield* Deferred.succeed(removalStarted, undefined);
|
||||
yield* Effect.sleep("31 seconds");
|
||||
}
|
||||
return yield* delegate.spawn(command);
|
||||
}),
|
||||
);
|
||||
const driver = yield* makeGitVcsDriverCore().pipe(
|
||||
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, delayedRemovalSpawner),
|
||||
Effect.provide(ServerConfigLayer),
|
||||
);
|
||||
const cwd = yield* makeTmpDir();
|
||||
const { initialBranch } = yield* initRepoWithCommit(cwd);
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const pathService = yield* Path.Path;
|
||||
const worktreePath = pathService.join(yield* makeTmpDir("git-worktrees-"), "slow-removal");
|
||||
|
||||
yield* driver.createWorktree({
|
||||
cwd,
|
||||
path: worktreePath,
|
||||
refName: initialBranch,
|
||||
newRefName: "feature/slow-removal",
|
||||
});
|
||||
|
||||
const removal = yield* driver
|
||||
.removeWorktree({ cwd, path: worktreePath, force: true })
|
||||
.pipe(Effect.forkChild({ startImmediately: true }));
|
||||
yield* Deferred.await(removalStarted);
|
||||
yield* TestClock.adjust("31 seconds");
|
||||
yield* Fiber.join(removal);
|
||||
|
||||
assert.equal(yield* fileSystem.exists(worktreePath), false);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("removes the same worktree path twice without failing", () =>
|
||||
Effect.gen(function* () {
|
||||
const cwd = yield* makeTmpDir();
|
||||
|
||||
@@ -43,6 +43,7 @@ const DEFAULT_TIMEOUT_MS = 30_000;
|
||||
// take well beyond the default 30s (e.g. a 375k-file repo takes ~40s on an idle
|
||||
// machine). Give it generous headroom while still bounding a genuinely hung git.
|
||||
const WORKTREE_ADD_TIMEOUT_MS = 300_000;
|
||||
const WORKTREE_REMOVE_TIMEOUT_MS = Duration.toMillis(Duration.minutes(5));
|
||||
const DEFAULT_MAX_OUTPUT_BYTES = 1_000_000;
|
||||
const OUTPUT_TRUNCATED_MARKER = "\n\n[truncated]";
|
||||
const PREPARED_COMMIT_PATCH_MAX_OUTPUT_BYTES = 49_000;
|
||||
@@ -3085,7 +3086,13 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
"GitVcsDriver.removeWorktree",
|
||||
input.cwd,
|
||||
args,
|
||||
{ timeoutMs: 15_000, allowNonZeroExit: true },
|
||||
{
|
||||
// Removing dependency-heavy worktrees is filesystem-bound and can take
|
||||
// minutes, especially on Windows. Keep it bounded without interrupting
|
||||
// git midway through cleanup.
|
||||
timeoutMs: WORKTREE_REMOVE_TIMEOUT_MS,
|
||||
allowNonZeroExit: true,
|
||||
},
|
||||
);
|
||||
if (result.exitCode === 0) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user