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: make sweepStrayTempRoots platform-aware with longer delays on Windows (#9045)

[._.]/ Adam Eivy81fde2ab5768
diff --git a/server/lib/mockPathsDataRoot.js b/server/lib/mockPathsDataRoot.js
index 7d876c4749..a337aab09c 100644
--- a/server/lib/mockPathsDataRoot.js
+++ b/server/lib/mockPathsDataRoot.js
@@ -109,12 +109,14 @@ export function cleanupTempDataRoots() {
* `server/services/musicVideo/compositionRender.test.js` and
* `server/routes/musicVideoVocalStem.test.js` are the worked examples.
*
- * Runs the sweep twice, ~300ms apart: a single pass right after
- * `cleanupTempDataRoots()` can still race a background job that has not
+ * On macOS and Linux, runs the sweep twice, ~300ms apart: a single pass right
+ * after `cleanupTempDataRoots()` can still race a background job that has not
* started writing yet (observed on CI's slower/more contended runners, not
* reproduced in ~10 local runs) — the second pass catches what the first
- * one was too early for. `await` this call as the LAST statement of the
- * suite's `afterAll`.
+ * one was too early for. On Windows, where process teardown is slower and
+ * file handles persist longer, runs additional sweeps with longer delays
+ * to accommodate lingering ffprobe/ffmpeg handles (#9045).
+ * `await` this call as the LAST statement of the suite's `afterAll`.
*/
export async function sweepStrayTempRoots(prefix) {
const sweepOnce = () => {
@@ -129,9 +131,13 @@ export async function sweepStrayTempRoots(prefix) {
if (name.startsWith(prefix)) rmSync(join(root, name), { recursive: true, force: true });
}
};
+ const isWindows = process.platform === 'win32';
+ const delays = isWindows ? [300, 500, 800] : [300];
sweepOnce();
- await new Promise((resolve) => { setTimeout(resolve, 300); });
- sweepOnce();
+ for (const delayMs of delays) {
+ await new Promise((resolve) => { setTimeout(resolve, delayMs); });
+ sweepOnce();
+ }
}
/**
diff --git a/server/test/runTempRoot.js b/server/test/runTempRoot.js
index 9a23b0ce28..6f77d2b1a1 100644
--- a/server/test/runTempRoot.js
+++ b/server/test/runTempRoot.js
@@ -62,16 +62,6 @@ const KNOWN_THIRD_PARTY_CLI_SCRATCH = new Set(['kilo', 'opencode', 'escape', 'no
// closed the identical symptom in two other real-ffmpeg/real-browser
// suites). Remove this entry once #9044 lands.
//
-// `mv-vocal-stem-route-test-` (server/routes/musicVideoVocalStem.test.js)
-// and `portos-mv-composition-` (server/services/musicVideo/compositionRender
-// .test.js) both already use that same sweepStrayTempRoots() helper, and it
-// reliably closes the leak on macOS and on CI's Linux server-test shards —
-// but NOT on Windows CI, where a still-terminating ffprobe/ffmpeg child
-// evidently holds its file handle past the helper's ~300ms retry window.
-// Tracked in #9045 (make the retry window platform-aware, or find and
-// directly await the still-running background work instead of retrying
-// blind). Remove these two entries once #9045 lands.
-//
// `mediaJobQueue-test-` (server/services/mediaJobQueue/index.test.js) is
// the same "not the right place to fix" case as the htmlComposition entry
// above — that tree is a different work area, out of scope for #9032 —
@@ -79,8 +69,6 @@ const KNOWN_THIRD_PARTY_CLI_SCRATCH = new Set(['kilo', 'opencode', 'escape', 'no
// once #9046 lands.
const KNOWN_PENDING_LEAKS = new Set([
'portos-html-composition-preflight-',
- 'mv-vocal-stem-route-test-',
- 'portos-mv-composition-',
'mediaJobQueue-test-',
]);