From c2a8e56d33b25cab6c4b7e26bad38722091bb015 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Thu, 16 Apr 2026 17:00:01 +0700 Subject: [PATCH] test(server): reproduce Windows EINVAL for .cmd shim with shell:false --- .../src/utils/spawn.launch-regression.test.ts | 16 ++++++++++++++++ packages/server/src/utils/spawn.ts | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/server/src/utils/spawn.launch-regression.test.ts b/packages/server/src/utils/spawn.launch-regression.test.ts index 1ef258edf..b43b88e1a 100644 --- a/packages/server/src/utils/spawn.launch-regression.test.ts +++ b/packages/server/src/utils/spawn.launch-regression.test.ts @@ -136,6 +136,22 @@ describe.runIf(process.platform === "win32")("Windows spawn launch regression", expect(result.stdout.trim()).toBe("ARGV_OK"); }); + test("launches a cmd shim even when the caller explicitly disables shell", async () => { + const fixture = makeFixture(); + + const result = await runFixture({ + command: fixture.shim, + args: fixture.expectedArgs, + shell: false, + }); + + expect(result.error).toBeNull(); + expect(result.code).toBe(0); + expect(result.signal).toBeNull(); + expect(result.stderr).toBe(""); + expect(result.stdout.trim()).toBe("ARGV_OK"); + }); + test("direct launch with a space-containing executable preserves JSON args", async () => { const fixture = makeFixture(); diff --git a/packages/server/src/utils/spawn.ts b/packages/server/src/utils/spawn.ts index f7a0b0881..5e0bbaa18 100644 --- a/packages/server/src/utils/spawn.ts +++ b/packages/server/src/utils/spawn.ts @@ -24,7 +24,7 @@ export function spawnProcess( options?: SpawnOptions, ): ChildProcess { const isWindows = process.platform === "win32"; - const shell = isWindowsCommandScript(command) ? true : (options?.shell ?? isWindows); + const shell = options?.shell ?? isWindows; const shouldQuoteForShell = isWindows && shell !== false; const resolvedCommand = shouldQuoteForShell ? quoteWindowsCommand(command) : command;