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.
This commit is contained in:
nvrl committed 2026-10-21 12:09:14 +02:00
1 parent 480eab0c6a
commit 10103b81be
1 file changed
+9 -1
+9 -1
View File
@@ -27,7 +27,15 @@ function cleanup() {
for (const child of children) child.kill() for (const child of children) child.kill()
rmSync(dir, { recursive: true, force: true }) 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) 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)) const sleep = (ms: number) => new Promise((done) => setTimeout(done, ms))
@@ -427,4 +435,4 @@ await open('/n/work')
await shot('mobile-tree') await shot('mobile-tree')
socket.close() socket.close()
process.exit(0) await finish()