fix(server): allow long-running git pushes (#6499)

This commit is contained in:
Dev Talan authored and GitHub committed 2026-08-15 12:26:27 +00:00
1 parent d550b829bd
commit 86fb47afd7
3 files changed
+67 -25

No files matched your search

+1 -1
View File
@@ -41,7 +41,7 @@ export interface ExecuteGitInput {
readonly stdin?: string;
readonly env?: NodeJS.ProcessEnv;
readonly allowNonZeroExit?: boolean;
readonly timeoutMs?: number;
readonly timeoutMs?: number | null;
readonly maxOutputBytes?: number;
readonly appendTruncationMarker?: boolean;
readonly progress?: ExecuteGitProgress;
@@ -1611,6 +1611,43 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
}),
);
it.effect("allows pushes to run longer than the default command timeout", () =>
Effect.gen(function* () {
const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;
const pushStarted = yield* Deferred.make<void>();
const delayedPushSpawner = ChildProcessSpawner.make((command) =>
Effect.gen(function* () {
if (ChildProcess.isStandardCommand(command) && command.args[0] === "push") {
yield* Deferred.succeed(pushStarted, undefined);
yield* Effect.sleep("31 seconds");
}
return yield* delegate.spawn(command);
}),
);
const driver = yield* makeGitVcsDriverCore().pipe(
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, delayedPushSpawner),
Effect.provide(ServerConfigLayer),
);
const cwd = yield* makeTmpDir();
const remote = yield* makeTmpDir("git-remote-");
yield* initRepoWithCommit(cwd);
yield* git(remote, ["init", "--bare"]);
yield* git(cwd, ["remote", "add", "origin", remote]);
const pushing = yield* driver
.pushCurrentBranch(cwd, null)
.pipe(Effect.forkChild({ startImmediately: true }));
yield* Deferred.await(pushStarted);
yield* TestClock.adjust("31 seconds");
const pushed = yield* Fiber.join(pushing);
assert.deepInclude(pushed, {
status: "pushed",
setUpstream: true,
});
}),
);
it.effect(
"pushes upstream branches to the remote branch name, not the upstream shorthand",
() =>
+29 -24
View File
@@ -139,7 +139,7 @@ interface GitRefsSnapshot {
interface ExecuteGitOptions {
stdin?: string | undefined;
timeoutMs?: number | undefined;
timeoutMs?: number | null | undefined;
allowNonZeroExit?: boolean | undefined;
fallbackErrorDetail?: string | undefined;
env?: NodeJS.ProcessEnv | undefined;
@@ -712,7 +712,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
...input,
args: [...input.args],
} as const;
const timeoutMs = input.timeoutMs ?? DEFAULT_TIMEOUT_MS;
const timeoutMs = input.timeoutMs === undefined ? DEFAULT_TIMEOUT_MS : input.timeoutMs;
const maxOutputBytes = input.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES;
const appendTruncationMarker = input.appendTruncationMarker ?? false;
@@ -813,8 +813,12 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
} satisfies GitVcsDriver.ExecuteGitResult;
});
return yield* runGitCommand().pipe(
Effect.scoped,
const execution = runGitCommand().pipe(Effect.scoped);
if (timeoutMs === null) {
return yield* execution;
}
return yield* execution.pipe(
Effect.timeoutOption(timeoutMs),
Effect.flatMap((result) =>
Option.match(result, {
@@ -905,9 +909,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
operation: string,
cwd: string,
args: readonly string[],
allowNonZeroExit = false,
options: ExecuteGitOptions = {},
): Effect.Effect<void, GitCommandError> =>
executeGit(operation, cwd, args, { allowNonZeroExit }).pipe(Effect.asVoid);
executeGit(operation, cwd, args, options).pipe(Effect.asVoid);
const runGitStdout = (
operation: string,
@@ -1905,12 +1909,12 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
const requestedRemoteName = options?.remoteName?.trim() || null;
if (requestedRemoteName) {
const publishBranch = yield* resolvePublishBranchName(cwd, branch);
yield* runGit("GitVcsDriver.pushCurrentBranch.pushWithRequestedRemote", cwd, [
"push",
"-u",
requestedRemoteName,
`HEAD:refs/heads/${publishBranch}`,
]);
yield* runGit(
"GitVcsDriver.pushCurrentBranch.pushWithRequestedRemote",
cwd,
["push", "-u", requestedRemoteName, `HEAD:refs/heads/${publishBranch}`],
{ timeoutMs: null },
);
return {
status: "pushed" as const,
branch,
@@ -1968,12 +1972,12 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
});
}
const publishBranch = yield* resolvePublishBranchName(cwd, branch);
yield* runGit("GitVcsDriver.pushCurrentBranch.pushWithUpstream", cwd, [
"push",
"-u",
publishRemoteName,
`HEAD:refs/heads/${publishBranch}`,
]);
yield* runGit(
"GitVcsDriver.pushCurrentBranch.pushWithUpstream",
cwd,
["push", "-u", publishRemoteName, `HEAD:refs/heads/${publishBranch}`],
{ timeoutMs: null },
);
return {
status: "pushed" as const,
branch,
@@ -1986,11 +1990,12 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
Effect.orElseSucceed(() => null),
);
if (currentUpstream) {
yield* runGit("GitVcsDriver.pushCurrentBranch.pushUpstream", cwd, [
"push",
currentUpstream.remoteName,
`HEAD:refs/heads/${currentUpstream.branchName}`,
]);
yield* runGit(
"GitVcsDriver.pushCurrentBranch.pushUpstream",
cwd,
["push", currentUpstream.remoteName, `HEAD:refs/heads/${currentUpstream.branchName}`],
{ timeoutMs: null },
);
return {
status: "pushed" as const,
branch,
@@ -1999,7 +2004,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
};
}
yield* runGit("GitVcsDriver.pushCurrentBranch.push", cwd, ["push"]);
yield* runGit("GitVcsDriver.pushCurrentBranch.push", cwd, ["push"], { timeoutMs: null });
return {
status: "pushed" as const,
branch,