From f71591d5a3956728f1067a0a10cd43b2a2c100be Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" <266920839+paseo-bot[bot]@users.noreply.github.com> Date: Sun, 25 Oct 2026 12:44:57 +0000 Subject: [PATCH] test(server): accept reset connections from timed-out Git helpers Force-killed Windows helpers reset their TCP sockets. Silent-remote fixtures must handle ECONNRESET while continuing to fail on unexpected socket errors. --- .../src/utils/run-git-command.windows-shell.test.ts | 6 ++++++ packages/server/src/utils/worktree.test.ts | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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 {