Skip to content

Commit 14bb554

Browse files
committed
fix(tests): avoid spreading process.env in spawn calls
Spreading process.env creates a plain object that loses Node.js's special Proxy behavior for environment variables on Windows. This breaks case-insensitive env var access (PATH vs Path vs path) and causes spawned CLI processes to have broken environment variables, resulting in empty output. Fix by conditionally building env object: use direct reference when no spawnEnv is provided, only spread when merging custom env vars.
1 parent bc941d2 commit 14bb554

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/cli/test/utils.mts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,13 @@ export async function spawnSocketCli(
266266
const commandArgs = isJsFile ? [entryPath, ...args] : args
267267

268268
try {
269+
// Build env without spreading process.env to preserve Windows proxy behavior.
270+
// Spreading process.env breaks case-insensitive env var access on Windows.
271+
const env = spawnEnv ? { ...constants.processEnv, ...spawnEnv } : constants.processEnv
272+
269273
const output = await spawn(command, commandArgs, {
270274
cwd,
271-
env: {
272-
...process.env,
273-
...constants.processEnv,
274-
...spawnEnv,
275-
},
275+
env,
276276
...restOptions,
277277
// Close stdin to prevent tests from hanging
278278
// when commands wait for input. Must be after restOptions

0 commit comments

Comments
 (0)