Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(vibe-tests): use unique temp dirs for preview builds (#489)

Cindy Zhangf8263e129772
diff --git a/internal/vibe-tests/.gitignore b/internal/vibe-tests/.gitignore
index 83c02ab99c..a6586984b6 100644
--- a/internal/vibe-tests/.gitignore
+++ b/internal/vibe-tests/.gitignore
@@ -14,3 +14,7 @@ AGENTS.html.md
# Test results (generated)
results/
+
+# Preview build temp dirs
+.preview-tmp*
+.baseline-shims/
diff --git a/internal/vibe-tests/src/build-previews.ts b/internal/vibe-tests/src/build-previews.ts
index fea476059d..b9c6751464 100644
--- a/internal/vibe-tests/src/build-previews.ts
+++ b/internal/vibe-tests/src/build-previews.ts
@@ -12,6 +12,7 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
+import * as crypto from 'node:crypto';
import {execSync} from 'node:child_process';
import {getResultsDir, ensureDir, readJson, writeJson} from './utils.js';
@@ -500,8 +501,12 @@ function buildPreview(
promptId: string,
outPath: string,
): boolean {
- const tmpDir = path.join(VIBE_DIR, '.preview-tmp');
- if (fs.existsSync(tmpDir)) fs.rmSync(tmpDir, {recursive: true});
+ // Use a unique temp directory per build to prevent race conditions
+ // when multiple build-previews processes run concurrently
+ const tmpDir = path.join(
+ VIBE_DIR,
+ `.preview-tmp-${crypto.randomUUID()}`,
+ );
ensureDir(tmpDir);
try {