Skip to content

Commit e181258

Browse files
committed
test(cli): build the collision children's env through childEnv, not a bare spread
`check:cli-test-child-env` is the gate that keeps `packages/cli/test`'s spawners off `{ ...process.env }`: vitest sets `TEST`, `VITEST` and the `VITEST_*` family on its worker, and a child inheriting them boots with a different auth and crypto posture than the one under test. The new collision pin spawned its children with a bare spread and the gate's shrink-only ratchet named it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D47qPfEWVPmhguWgBZCi5N
1 parent 7c5ef29 commit e181258

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

packages/cli/test/serve-runtime-state-project-key.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import { join, resolve } from 'node:path';
5050
import { fileURLToPath } from 'node:url';
5151

5252
import { projectStateKey, runtimeStateFileName } from '../src/commands/serve.js';
53-
import { TSX } from './helpers/serve-process.js';
53+
import { childEnv, TSX } from './helpers/serve-process.js';
5454

5555
const HERE = resolve(fileURLToPath(import.meta.url), '..');
5656
const CHILD = resolve(HERE, 'helpers/runtime-state-child.ts');
@@ -99,12 +99,16 @@ function publishFrom(projectRoot: string, home: string, port: number): Promise<C
9999
const child: ChildProcess = spawn(TSX, [CHILD, String(port), NAMING_CONTROL_ROOT], {
100100
cwd: projectRoot,
101101
stdio: ['pipe', 'pipe', 'pipe'],
102-
env: {
103-
...process.env,
102+
// ⛔ `childEnv`, never a bare `...process.env`: vitest sets `TEST`,
103+
// `VITEST` and the `VITEST_*` family on its worker, and a child that
104+
// inherits them boots with a different auth and crypto posture than the
105+
// one under test (`check:cli-test-child-env` is the gate that keeps this
106+
// directory on the choke point).
107+
env: childEnv({
104108
OS_HOME: home,
105109
// UNSET, so the environment half of the name is serve's own default.
106110
OS_ENVIRONMENT_ID: undefined,
107-
},
111+
}),
108112
});
109113
childrenSpawned += 1;
110114

0 commit comments

Comments
 (0)