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: remove git fixture templates after each test file instead of on worker exit (#9000)

[._.]/ Adam Eivy3cec6a3818cd
diff --git a/server/vitest.setup.js b/server/vitest.setup.js
index f3d392918b..0d1e5318f7 100644
--- a/server/vitest.setup.js
+++ b/server/vitest.setup.js
@@ -50,6 +50,7 @@
* suites (Option B) for working examples.
*/
+import { rmSync } from 'fs';
import { mockNoPeers } from './lib/mockPathsDataRoot.js';
// The server intentionally logs expected error paths, lifecycle transitions,
@@ -71,3 +72,18 @@ vi.mock('./services/instances.js', async (importOriginal) => {
const actual = await importOriginal();
return mockNoPeers(actual);
});
+
+// Wipe the shared git fixture templates (`lib/gitTestRepo.js`) after each
+// test file (#9000). Vitest isolates the module graph per file, so every file
+// that uses the helper builds its own template, and the helper's
+// `process.on('exit')` hook never fires when the pool tears a worker down.
+// Without this, one `portos-git-template-*` dir leaked per file per run.
+// Read from globalThis rather than importing the helper, so files that never
+// touch git don't pay for its import graph.
+afterAll(() => {
+ const dirs = globalThis.__portosGitTemplateDirs;
+ if (!Array.isArray(dirs)) return;
+ for (const dir of dirs.splice(0)) {
+ try { rmSync(dir, { recursive: true, force: true }); } catch { /* already gone */ }
+ }
+});