fix(scripts): smoke.mjs kills Chrome's whole process group so the temp profile is removed

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
Lucas Winther
2026-10-28 23:53:45 +01:00
co-authored by Claude Sonnet 5.5
parent 8028bb2fc0
commit 25141ce86d
+6 -2
View File
@@ -23,8 +23,12 @@ const port = await freePort()
const chrome = spawn(chromePath, [
'--headless=new', `--remote-debugging-port=${port}`, `--user-data-dir=${dir}`,
'--no-sandbox', '--disable-gpu', '--no-first-run', 'about:blank',
], { stdio: 'ignore' })
const cleanup = () => { chrome.kill('SIGKILL'); rmSync(dir, { recursive: true, force: true }) }
], { stdio: 'ignore', detached: true })
// Chrome forks helper processes; kill the whole process group, then remove the profile dir.
const cleanup = () => {
try { process.kill(-chrome.pid, 'SIGKILL') } catch {}
rmSync(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 })
}
const finish = (code, msg) => { if (msg) console.log(msg); cleanup(); process.exit(code) }
process.on('SIGINT', () => finish(1, 'interrupted'))
const timer = setTimeout(() => finish(1, 'FAIL: timed out'), 30000)