From 10103b81be87c00f92436a31971e3c53b9994d27 Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Wed, 21 Oct 2026 12:09:14 +0200 Subject: [PATCH] docs: the screenshot run leaves no directory behind The temporary data directory was removed on exit while Chromium was still writing its profile into it, so the removal failed quietly and one directory per run stayed in /tmp. The run now waits for the server and the browser to exit before removing it; the exit handler stays for a run that crashes. --- scripts/screenshots.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/screenshots.ts b/scripts/screenshots.ts index 1882269..19ec9d3 100644 --- a/scripts/screenshots.ts +++ b/scripts/screenshots.ts @@ -27,7 +27,15 @@ function cleanup() { for (const child of children) child.kill() rmSync(dir, { recursive: true, force: true }) } +// A crash still stops the server and the browser; the directory may outlive +// them then, since Chromium writes its profile until it has exited. process.on('exit', cleanup) +async function finish() { + for (const child of children) child.kill() + await Promise.all(children.map((child) => child.exited)) + rmSync(dir, { recursive: true, force: true }) + process.exit(0) +} const sleep = (ms: number) => new Promise((done) => setTimeout(done, ms)) @@ -427,4 +435,4 @@ await open('/n/work') await shot('mobile-tree') socket.close() -process.exit(0) +await finish()