Skip to content

Commit 0b86233

Browse files
committed
fix(tests): revert to working spawn pattern from commit 39ee946
The Proxy approach added unnecessary complexity. The real fix was ensuring constants.processEnv is a direct reference to process.env (not a snapshot), which we already have at line 30. The working pattern from commit 39ee946: - constants.processEnv = process.env (direct Proxy reference) - Spawn spreads: {...process.env, ...constants.processEnv, ...spawnEnv} - VITEST=1 set on actual process.env at module load (lines 23-24) This preserves Windows Proxy behavior because spreading a Proxy creates a fresh snapshot each spawn, not a stale object.
1 parent be5fc27 commit 0b86233

File tree

1 file changed

+5
-42
lines changed

1 file changed

+5
-42
lines changed

packages/cli/test/utils.mts

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

268268
try {
269-
// In test mode, use a Proxy to preserve Windows process.env Proxy behavior.
270-
// In production, use a static snapshot for performance.
271-
const env = process.env['VITEST']
272-
? new Proxy(
273-
{},
274-
{
275-
get(_target, prop) {
276-
// Priority: spawnEnv > constants.processEnv
277-
if (spawnEnv && prop in spawnEnv) {
278-
return spawnEnv[prop]
279-
}
280-
return constants.processEnv[prop]
281-
},
282-
ownKeys(_target) {
283-
const keys = new Set([
284-
...Object.keys(constants.processEnv),
285-
...(spawnEnv ? Object.keys(spawnEnv) : []),
286-
])
287-
return [...keys]
288-
},
289-
getOwnPropertyDescriptor(_target, prop) {
290-
const value =
291-
(spawnEnv && prop in spawnEnv
292-
? spawnEnv[prop]
293-
: constants.processEnv[prop]) ?? undefined
294-
return value !== undefined
295-
? {
296-
enumerable: true,
297-
configurable: true,
298-
value,
299-
}
300-
: undefined
301-
},
302-
},
303-
)
304-
: {
305-
...process.env,
306-
...constants.processEnv,
307-
...spawnEnv,
308-
}
309-
310269
const output = await spawn(command, commandArgs, {
311270
cwd,
312-
env,
271+
env: {
272+
...process.env,
273+
...constants.processEnv,
274+
...spawnEnv,
275+
},
313276
...restOptions,
314277
// Close stdin to prevent tests from hanging
315278
// when commands wait for input. Must be after restOptions

0 commit comments

Comments
 (0)