fix(scripts): smoke.mjs kills Chrome's whole process group so the temp profile is removed
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8028bb2fc0
commit
25141ce86d
1 file changed
+6
-2
+6
-2
@@ -23,8 +23,12 @@ const port = await freePort()
|
|||||||
const chrome = spawn(chromePath, [
|
const chrome = spawn(chromePath, [
|
||||||
'--headless=new', `--remote-debugging-port=${port}`, `--user-data-dir=${dir}`,
|
'--headless=new', `--remote-debugging-port=${port}`, `--user-data-dir=${dir}`,
|
||||||
'--no-sandbox', '--disable-gpu', '--no-first-run', 'about:blank',
|
'--no-sandbox', '--disable-gpu', '--no-first-run', 'about:blank',
|
||||||
], { stdio: 'ignore' })
|
], { stdio: 'ignore', detached: true })
|
||||||
const cleanup = () => { chrome.kill('SIGKILL'); rmSync(dir, { recursive: true, force: 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) }
|
const finish = (code, msg) => { if (msg) console.log(msg); cleanup(); process.exit(code) }
|
||||||
process.on('SIGINT', () => finish(1, 'interrupted'))
|
process.on('SIGINT', () => finish(1, 'interrupted'))
|
||||||
const timer = setTimeout(() => finish(1, 'FAIL: timed out'), 30000)
|
const timer = setTimeout(() => finish(1, 'FAIL: timed out'), 30000)
|
||||||
|
|||||||
Reference in new issue
Block a user