Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(tracing): mkdir tracesDir before live .stacks writes (#40730)

Simon Knott00dcb5cd511e
diff --git a/packages/playwright-core/src/server/localUtils.ts b/packages/playwright-core/src/server/localUtils.ts
index b6c44cc7b5..3880e2f5dd 100644
--- a/packages/playwright-core/src/server/localUtils.ts
+++ b/packages/playwright-core/src/server/localUtils.ts
@@ -217,6 +217,9 @@ export async function tracingStarted(progress: Progress, stackSessions: Map<stri
if (!params.tracesDir)
tmpDir = await progress.race(fs.promises.mkdtemp(path.join(os.tmpdir(), 'playwright-tracing-')));
const traceStacksFile = path.join(params.tracesDir || tmpDir!, params.traceName + '.stacks');
+ // Ensure the directory exists before addStackToTracingNoReply races ahead of
+ // the tracing recorder's own (separately queued) mkdir.
+ await progress.race(fs.promises.mkdir(path.dirname(traceStacksFile), { recursive: true }));
stackSessions.set(traceStacksFile, { callStacks: [], file: traceStacksFile, writer: Promise.resolve(), tmpDir, live: params.live });
return { stacksId: traceStacksFile };
}