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

test: sweep mediaJobQueue temp roots once in afterAll, not per test (#9046)

[._.]/ Adam Eivye21d000f4a20
diff --git a/server/services/mediaJobQueue/index.test.js b/server/services/mediaJobQueue/index.test.js
index 49b00290ea..9f51ddadd6 100644
--- a/server/services/mediaJobQueue/index.test.js
+++ b/server/services/mediaJobQueue/index.test.js
@@ -1,8 +1,9 @@
-import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
+import { describe, it, expect, vi, beforeEach, afterEach, afterAll } from 'vitest';
import { mkdtempSync, mkdirSync, rmSync, writeFileSync, existsSync, readFileSync } from 'fs';
import { tmpdir } from 'os';
import { join } from 'path';
import { IMAGE_GEN_MODE } from '../imageGen/modes.js';
+import { sweepStrayTempRoots } from '../../lib/mockPathsDataRoot.js';
// The queue persists to data/media-jobs.json. Steer it at a temp dir so each
// test gets a clean slate without scribbling over the real data dir.
@@ -219,11 +220,12 @@ afterEach(async () => {
if (tempDataDir && existsSync(tempDataDir)) {
rmSync(tempDataDir, { recursive: true, force: true });
}
- // Windows holds file handles on terminating child processes longer than
- // macOS/Linux, so a single rmSync above may not catch all temp dirs yet.
- // Sweep the run's real tmpdir for any remaining mediaJobQueue-test-* dirs
- // with retry delays. See #9046, #9032.
- const { sweepStrayTempRoots } = await import('../../lib/mockPathsDataRoot.js');
+});
+
+// Late work (a debounced persist, a still-terminating child on Windows) can
+// recreate or pin a per-test temp dir after afterEach removed it (#9046) —
+// see sweepStrayTempRoots's doc.
+afterAll(async () => {
await sweepStrayTempRoots('mediaJobQueue-test-');
});
diff --git a/server/test/runTempRoot.js b/server/test/runTempRoot.js
index 69cdb69652..46fa816de9 100644
--- a/server/test/runTempRoot.js
+++ b/server/test/runTempRoot.js
@@ -77,7 +77,7 @@ const VITEST_INTERNAL_SCRATCH_DIR = /^[A-Za-z0-9_-]{21}$/;
// first place. No longer allowlisted below; a recurrence is a real,
// unknown leak again.
-const KNOWN_PENDING_LEAKS = new Set([]);
+const KNOWN_PENDING_LEAKS = new Set();
/**
* Groups a leaked entry's basename by its mkdtemp call site as closely as a