Skip to content

fix: disable Node's compile cache for the server test run (#9051) - #9058

Merged
atomantic merged 1 commit into
mainfrom
claim/issue-9051
Sep 28, 2026
Merged

atomantic merged 1 commit into
mainfrom
claim/issue-9051

Conversation

@atomantic

Copy link
Copy Markdown
Owner

Summary

node-compile-cache still turned up rarely in the run-scoped vitest temp root (server/test/runTempRoot.js) even after #9050 isolated the one confirmed real-CLI spawn (npmGlobalBin.js's npm prefix -g) into its own throwaway TMPDIR. Node's module compile cache is process-wide — written whenever NODE_COMPILE_CACHE is set or a CLI calls module.enableCompileCache() on itself (recent npm/npx builds do) — so no single spawn helper's TMPDIR isolation can be proven to cover every child process that might inherit the test run's TMPDIR.

  • server/vitest.config.js now sets NODE_DISABLE_COMPILE_CACHE=1 in both the main process env and every worker's test.env, so any child process — isolated TMPDIR or not — never writes the cache in the first place. Honored since Node v22.1, within this repo's supported engines range (^22.22.2 || ^24.15.0 || >=26.0.0).
  • Removed the now-unneeded KNOWN_THIRD_PARTY_CLI_SCRATCH allowlist (the set, its usage, and its leak-report note) from server/test/runTempRoot.js — a recurrence now fails the run again instead of being silently allowlisted.
  • Documented the new env var in server/envExampleDrift.test.js's INHERITED_ENV allowlist (a Node-provided switch, not a user-facing setting).

Test plan

Closes #9051

node-compile-cache still turned up rarely in the run-scoped vitest
temp root even after #9050 isolated the one confirmed real-CLI spawn
(npmGlobalBin.js's `npm prefix -g`) into its own TMPDIR. The cache is
process-wide (NODE_COMPILE_CACHE env, or a CLI calling
module.enableCompileCache() on itself), not tied to one call site, so
no single spawn helper's isolation could be proven to cover every
child that might inherit the run's TMPDIR.

Set NODE_DISABLE_COMPILE_CACHE=1 tree-wide for the test run instead
(server/vitest.config.js, main process and worker env) - honored
since Node v22.1, within this repo's supported range. Remove the
now-unneeded KNOWN_THIRD_PARTY_CLI_SCRATCH allowlist entry from
server/test/runTempRoot.js so a recurrence fails the run again.
Document the new env var in envExampleDrift.test.js's INHERITED_ENV
allowlist.
@atomantic
atomantic merged commit 2356cad into main Sep 28, 2026
14 checks passed
@atomantic
atomantic deleted the claim/issue-9051 branch September 28, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server test run still leaks node-compile-cache into the vitest run root

1 participant