@devries-cameron20 / t3code Mirror · read-only / commits / a33d50a539
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 19:45 UTC

fix(server): committing a large selection of files no longer fails with spawn E2BIG (#35128)

Julius Marminge committed Nov 12, 2026 at 02:49 UTC a33d50a5396fd2b34da02b0f3a8f27ff9b25dd02
2 files changed +45 -12
apps/server/src/vcs/GitVcsDriverCore.test.ts
+30 -1
@@ -1937,9 +1937,12 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
1937 yield* git(cwd, ["init"]);
1938 yield* git(cwd, ["config", "user.email", "test@test.com"]);
1939 yield* git(cwd, ["config", "user.name", "Test"]);
1940 + // Selected paths add up to more than Linux's default 2 MiB argument limit.
1941 + const dir = "d".repeat(200);
1942 + yield* fs.makeDirectory(path.join(cwd, dir));
1943 const files = Array.from(
1944 { length: 6_000 },
1942 - (_, index) => `file-${String(index).padStart(5, "0")}-${"x".repeat(160)}.txt`,
1945 + (_, index) => `${dir}/file-${String(index).padStart(5, "0")}-${"x".repeat(160)}.txt`,
1946 );
1947 yield* Effect.forEach(files, (file) => fs.writeFileString(path.join(cwd, file), "before\n"), {
1948 concurrency: 16,
@@ -1965,6 +1968,10 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
1968 assert.isNotNull(context);
1969 assert.isAbove(context!.stagedSummary.length, 1_000_000);
1970 assert.lengthOf(context!.stagedSummary.split("\n"), files.length);
1971 + const selected = files.slice(1);
1972 + yield* driver.commit(cwd, "selected", "", { stage: { filePaths: selected } });
1973 + assert.equal(yield* git(cwd, ["log", "-1", "--pretty=%s"]), "selected");
1974 + assert.equal(yield* git(cwd, ["status", "--porcelain"]), `M ${files[0]}`);
1975 }),
1976 );
1977 describe("structured errors", () => {
@@ -2000,6 +2007,28 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
2007 }),
2008 );
2009
2010 + it.effect("fails with a GitCommandError when spawn throws", () =>
2011 + Effect.gen(function* () {
2012 + const cwd = yield* makeTmpDir();
2013 + const driver = yield* GitVcsDriver.GitVcsDriver;
2014 +
2015 + // Over the OS argument limit, Node's spawn throws E2BIG synchronously.
2016 + const error = yield* driver
2017 + .execute({
2018 + operation: "GitVcsDriver.test.spawnThrow",
2019 + cwd,
2020 + args: ["status", "x".repeat(4 * 1024 * 1024)],
2021 + })
2022 + .pipe(Effect.flip);
2023 +
2024 + assert.deepInclude(error, {
2025 + _tag: "GitCommandError",
2026 + operation: "GitVcsDriver.test.spawnThrow",
2027 + detail: "Failed to spawn Git process.",
2028 + });
2029 + }),
2030 + );
2031 +
2032 // regression: #8645 name the cause of a failed git command
2033 it.effect("names the branch conflict behind a failed worktree add", () =>
2034 Effect.gen(function* () {
apps/server/src/vcs/GitVcsDriverCore.ts
+15 -11
@@ -1009,6 +1009,12 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
1009 const env = { ...baseEnv, ...explicitBareRepositoryEnv(baseEnv, hostPlatform) };
1010 const spawnEnv = { ...env, ...windowsLongPathConfigEnv(hostPlatform, env) };
1011 const resolved = yield* resolveSpawnCommand("git", [], { env: spawnEnv });
1012 + const spawnError = (cause: unknown) =>
1013 + new GitCommandError({
1014 + ...gitCommandContext(commandInput),
1015 + detail: "Failed to spawn Git process.",
1016 + cause,
1017 + });
1018 // cmd wrappers truncate multiline commits; leave git.cmd handling to Node lookup.
1019 const executable = resolved.shell ? "git" : resolved.command;
1020 const child = yield* commandSpawner
@@ -1024,14 +1030,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
1030 }),
1031 )
1032 .pipe(
1027 - Effect.mapError(
1028 - (cause) =>
1029 - new GitCommandError({
1030 - ...gitCommandContext(commandInput),
1031 - detail: "Failed to spawn Git process.",
1032 - cause,
1033 - }),
1034 - ),
1033 + Effect.mapError(spawnError),
1034 + // Synchronous spawn throws (such as E2BIG) arrive as defects.
1035 + Effect.catchDefect((cause) => Effect.fail(spawnError(cause))),
1036 );
1037
1038 const [stdout, stderr, exitCode] = yield* Effect.all(
@@ -2534,9 +2535,12 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
2535 yield* runGit(
2536 "GitVcsDriver.commit.addSelected",
2537 cwd,
2537 - // Status paths are repository-relative, while cwd can be a subdirectory.
2538 - [...config, "add", "-A", "--", ...filePaths.map((file) => `:(top,literal)${file}`)],
2539 - env ? { env } : {},
2538 + [...config, "add", "-A", "--pathspec-from-file=-", "--pathspec-file-nul"],
2539 + {
2540 + ...(env ? { env } : {}),
2541 + // Status paths are repository-relative, while cwd can be a subdirectory.
2542 + stdin: filePaths.map((file) => `:(top,literal)${file}\0`).join(""),
2543 + },
2544 );
2545 } else {
2546 yield* runGit(