Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions apps/server/src/vcs/GitVcsDriverCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1892,6 +1892,53 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
}),
);

it.effect("allows remote fetches to run longer than the default command timeout", () =>
Effect.gen(function* () {
const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;
const fetchStarted = yield* Deferred.make<void>();
const delayedFetchSpawner = ChildProcessSpawner.make((command) =>
Effect.gen(function* () {
if (ChildProcess.isStandardCommand(command) && command.args[0] === "fetch") {
yield* Deferred.succeed(fetchStarted, undefined);
yield* Effect.sleep("31 seconds");
}
return yield* delegate.spawn(command);
}),
);
const driver = yield* makeGitVcsDriverCore().pipe(
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, delayedFetchSpawner),
Effect.provide(ServerConfigLayer),
);
const cwd = yield* makeTmpDir();
const remote = yield* makeTmpDir("git-remote-");
const peer = yield* makeTmpDir("git-peer-");
const { initialBranch } = yield* initRepoWithCommit(cwd);
yield* git(remote, ["init", "--bare"]);
yield* git(cwd, ["remote", "add", "origin", remote]);
yield* git(cwd, ["push", "-u", "origin", initialBranch]);
yield* git(peer, ["clone", remote, "."]);
yield* git(peer, ["config", "user.email", "test@test.com"]);
yield* git(peer, ["config", "user.name", "Test"]);
yield* writeTextFile(peer, "remote-change.txt", "remote\n");
yield* git(peer, ["add", "remote-change.txt"]);
yield* git(peer, ["commit", "-m", "remote change"]);
yield* git(peer, ["push", "origin", initialBranch]);
const remoteHead = yield* git(peer, ["rev-parse", "HEAD"]);

const fetching = yield* driver
.fetchRemote({ cwd, remoteName: "origin" })
.pipe(Effect.forkChild({ startImmediately: true }));
yield* Deferred.await(fetchStarted);
yield* TestClock.adjust("31 seconds");
yield* Fiber.join(fetching);

assert.equal(
yield* git(cwd, ["rev-parse", `refs/remotes/origin/${initialBranch}`]),
remoteHead,
);
}),
);

it.effect("allows pushes to run longer than the default command timeout", () =>
Effect.gen(function* () {
const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;
Expand Down
3 changes: 3 additions & 0 deletions apps/server/src/vcs/GitVcsDriverCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3039,12 +3039,15 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*

const fetchRemote: GitVcsDriver.GitVcsDriver["Service"]["fetchRemote"] = Effect.fn("fetchRemote")(
function* (input) {
// A catch-up fetch of a large remote can run for minutes; the default
// 30s deadline kills it mid-pack and every retry starts over, like push.
yield* executeGit(
"GitVcsDriver.fetchRemote",
input.cwd,
["fetch", "--quiet", input.remoteName],
{
env: STATUS_UPSTREAM_REFRESH_ENV,
timeoutMs: null,
fallbackErrorDetail: `git fetch ${input.remoteName} failed`,
},
);
Expand Down
Loading