diff --git a/packages/server/src/utils/run-git-command.windows-shell.test.ts b/packages/server/src/utils/run-git-command.windows-shell.test.ts index d3db4bcbe2..34267926a8 100644 --- a/packages/server/src/utils/run-git-command.windows-shell.test.ts +++ b/packages/server/src/utils/run-git-command.windows-shell.test.ts @@ -8,6 +8,10 @@ import { runGitCommand } from "./run-git-command.js"; const tempDirs: string[] = []; +function allowConnectionReset(error: NodeJS.ErrnoException): void { + if (error.code !== "ECONNRESET") throw error; +} + function makeTempRepo(): string { const repo = mkdtempSync(path.join(tmpdir(), "paseo-git-shell-")); tempDirs.push(repo); @@ -29,6 +33,8 @@ describe("runGitCommand shell behavior", () => { const sockets: Socket[] = []; const server = createServer((socket) => { sockets.push(socket); + // Force-killing a Windows peer resets the connection instead of sending EOF. + socket.on("error", allowConnectionReset); // Consume the request but never answer, keeping the real transport helper busy. socket.resume(); }); diff --git a/packages/server/src/utils/worktree.test.ts b/packages/server/src/utils/worktree.test.ts index 4d6f50bba6..f0beeae745 100644 --- a/packages/server/src/utils/worktree.test.ts +++ b/packages/server/src/utils/worktree.test.ts @@ -55,10 +55,18 @@ function createLegacyWorktreeForTest( }); } +function allowConnectionReset(error: NodeJS.ErrnoException): void { + if (error.code !== "ECONNRESET") throw error; +} + // A remote that accepts connections and never answers, like a VPN-only host while off the VPN. async function startSilentRemote(): Promise<{ url: string; close: () => Promise }> { const connections = new Set(); - const server = createServer((socket) => connections.add(socket)); + const server = createServer((socket) => { + connections.add(socket); + // Timeout cleanup force-kills the peer, which can reset its connection on Windows. + socket.on("error", allowConnectionReset); + }); await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve)); const { port } = server.address() as AddressInfo; return {