From 02935d777a848e067778ad792c636b4c6e63082d Mon Sep 17 00:00:00 2001 From: Ran <8403607+eddieran@users.noreply.github.com> Date: Wed, 27 May 2026 12:38:28 +0800 Subject: [PATCH] test(vitest): unblock subprocess MCP tests on Node >= 25 dev machines (#478) (#479) Vitest already inherits process.env into every spawned `codegraph serve --mcp` child, but on Node >= 25 the CLI's hard-block (src/bin/codegraph.ts) kills the child before it can respond. Set CODEGRAPH_ALLOW_UNSAFE_NODE=1 via test.env so the test suite is green regardless of the contributor's Node version; the runtime guard itself is unchanged for end users. --- vitest.config.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vitest.config.ts b/vitest.config.ts index 2449a98..4a5ad90 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -5,6 +5,20 @@ export default defineConfig({ globals: true, environment: 'node', include: ['__tests__/**/*.test.ts'], + /** + * Several MCP integration tests (mcp-daemon, mcp-initialize, mcp-ppid-watchdog, + * mcp-roots) spawn `dist/bin/codegraph.js serve --mcp` with `process.execPath` + * and rely on the child inheriting `process.env`. On a Node >= 25 dev machine + * the CLI's hard-block (src/bin/codegraph.ts) would otherwise exit the child + * before it ever responds, so every spawn-based test times out — see #478. + * + * Setting the override here keeps the CLI's runtime guard intact for end + * users (it's still enforced when `codegraph` is invoked directly) while + * letting the test suite run on whatever Node the contributor happens to + * have installed. CI on Node 22/23 is unaffected — the guard doesn't fire + * there, so the variable is a no-op. + */ + env: { CODEGRAPH_ALLOW_UNSAFE_NODE: '1' }, coverage: { provider: 'v8', reporter: ['text', 'json', 'html'],