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: retry sweepStrayTempRoots after a short delay to beat a CI-only race

[._.]/ Adam Eivyab0202881c80
diff --git a/server/lib/mockPathsDataRoot.js b/server/lib/mockPathsDataRoot.js
index 7ccdff9c02..7d876c4749 100644
--- a/server/lib/mockPathsDataRoot.js
+++ b/server/lib/mockPathsDataRoot.js
@@ -108,18 +108,30 @@ export function cleanupTempDataRoots() {
* running background job can still recreate the prefix afterward) that race.
* `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
+ * 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`.
*/
-export function sweepStrayTempRoots(prefix) {
- const root = tmpdir();
- let entries;
- try {
- entries = readdirSync(root);
- } catch {
- return;
- }
- for (const name of entries) {
- if (name.startsWith(prefix)) rmSync(join(root, name), { recursive: true, force: true });
- }
+export async function sweepStrayTempRoots(prefix) {
+ const sweepOnce = () => {
+ const root = tmpdir();
+ let entries;
+ try {
+ entries = readdirSync(root);
+ } catch {
+ return;
+ }
+ for (const name of entries) {
+ if (name.startsWith(prefix)) rmSync(join(root, name), { recursive: true, force: true });
+ }
+ };
+ sweepOnce();
+ await new Promise((resolve) => { setTimeout(resolve, 300); });
+ sweepOnce();
}
/**
diff --git a/server/routes/musicVideoVocalStem.test.js b/server/routes/musicVideoVocalStem.test.js
index da37405b6a..1fd27429e7 100644
--- a/server/routes/musicVideoVocalStem.test.js
+++ b/server/routes/musicVideoVocalStem.test.js
@@ -62,10 +62,10 @@ beforeEach(async () => {
writeFileSync(join(MUSIC(), 'other-song.wav'), wav(6));
project = await projects.createProject({ name: 'Example Video', uploadedAudioFilename: 'song.wav' });
});
-afterAll(() => {
+afterAll(async () => {
cleanupTempDataRoots();
// Real ffprobe/ffmpeg subprocess work (#9032) — see sweepStrayTempRoots's doc.
- sweepStrayTempRoots('mv-vocal-stem-route-test-');
+ await sweepStrayTempRoots('mv-vocal-stem-route-test-');
});
describe.skipIf(!ffmpeg)('music-video vocal stem routes', () => {
diff --git a/server/services/musicVideo/compositionRender.test.js b/server/services/musicVideo/compositionRender.test.js
index 748ac7270a..7f85fbd932 100644
--- a/server/services/musicVideo/compositionRender.test.js
+++ b/server/services/musicVideo/compositionRender.test.js
@@ -68,7 +68,7 @@ describe.skipIf(!chrome || !ffmpeg)('music-video typography overlay with real Ch
afterAll(async () => {
await _cleanupTestBrowser({ browser, proc, cleanup: cleanupTempDataRoots });
// Real ffprobe/ffmpeg subprocess work (#9032) — see sweepStrayTempRoots's doc.
- sweepStrayTempRoots('portos-mv-composition-');
+ await sweepStrayTempRoots('portos-mv-composition-');
});
it('lays timed text over the cut on one continuous audio master, covering the edit within a frame', async () => {