Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: keep test-spawned npm from evicting the developer's npm debug logs (#11685)

[._.]/ Adam Eivy34dc0c6dfbc5
diff --git a/client/vitest.config.js b/client/vitest.config.js
index 96bc747737..a7590850c4 100644
--- a/client/vitest.config.js
+++ b/client/vitest.config.js
@@ -23,6 +23,8 @@ export default defineConfig({
TMP: RUN_TEMP_ROOT,
TEMP: RUN_TEMP_ROOT,
MAC_CHROMIUM_TMPDIR: RUN_TEMP_ROOT,
+ // Keeps spawned npm from writing debug logs into the developer's ~/.npm/_logs.
+ npm_config_logs_max: '0',
NODE_DISABLE_COMPILE_CACHE: '1',
},
// Four DOM workers exhausted Testing Library's async budget on the public
diff --git a/scripts/lib/vitestTempRoot.js b/scripts/lib/vitestTempRoot.js
index e288be64da..d7cdb41585 100644
--- a/scripts/lib/vitestTempRoot.js
+++ b/scripts/lib/vitestTempRoot.js
@@ -63,5 +63,7 @@ export function bootstrapVitestTempRoot() {
// test-owned socket/download scratch escapes the root and its teardown.
process.env.MAC_CHROMIUM_TMPDIR = root;
process.env.NODE_DISABLE_COMPILE_CACHE = '1';
+ // Spawned npm would otherwise write debug logs into the developer's ~/.npm/_logs, evicting real ones (logs-max default 10).
+ process.env.npm_config_logs_max = '0';
return root;
}
diff --git a/scripts/vitestTempRoot.test.js b/scripts/vitestTempRoot.test.js
index 3117f9e64a..3b6f135c37 100644
--- a/scripts/vitestTempRoot.test.js
+++ b/scripts/vitestTempRoot.test.js
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { spawn, spawnSync } from 'node:child_process';
-import { existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync, utimesSync, writeFileSync } from 'node:fs';
+import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, utimesSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join, relative } from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -193,3 +193,19 @@ describe.skipIf(process.platform === 'win32')('orphaned test browser sweep', ()
}
}, 20000);
});
+
+describe('npm debug log containment', () => {
+ const repo = fileURLToPath(new URL('../', import.meta.url));
+ it.each(['server/vitest.config.js', 'server/vitest.config.db.js', 'client/vitest.config.js'])(
+ '%s disables npm log files for workers',
+ config => {
+ const source = readFileSync(join(repo, config), 'utf8');
+ expect(source).toMatch(/npm_config_logs_max:\s*'0'/);
+ },
+ );
+
+ it('bootstrap disables npm log files for the runner process', () => {
+ const source = readFileSync(join(repo, 'scripts/lib/vitestTempRoot.js'), 'utf8');
+ expect(source).toMatch(/process\.env\.npm_config_logs_max\s*=\s*'0'/);
+ });
+});
diff --git a/server/vitest.config.db.js b/server/vitest.config.db.js
index 7cd9d0cd9b..163cfebfa7 100644
--- a/server/vitest.config.db.js
+++ b/server/vitest.config.db.js
@@ -58,6 +58,8 @@ export default defineConfig({
TMP: RUN_TEMP_ROOT,
TEMP: RUN_TEMP_ROOT,
MAC_CHROMIUM_TMPDIR: RUN_TEMP_ROOT,
+ // Keeps spawned npm from writing debug logs into the developer's ~/.npm/_logs.
+ npm_config_logs_max: '0',
},
include: DB_TEST_INCLUDE,
exclude: [
diff --git a/server/vitest.config.js b/server/vitest.config.js
index 073a1d087c..61d92757cc 100644
--- a/server/vitest.config.js
+++ b/server/vitest.config.js
@@ -61,6 +61,8 @@ const config = defineConfig({
TMP: RUN_TEMP_ROOT,
TEMP: RUN_TEMP_ROOT,
MAC_CHROMIUM_TMPDIR: RUN_TEMP_ROOT,
+ // Keeps spawned npm from writing debug logs into the developer's ~/.npm/_logs.
+ npm_config_logs_max: '0',
},
// 30s on every platform (#7951). This WAS 10s off Windows, and the split
// has always been a fiction: the cost it budgets for is vitest's transform