Summary
Follow-up to the crawl-lifetime fix (crawl now runs in the background to its own maxPages/empty queue instead of dying at turn-end). With that change, a background crawl can be alive when the server process exits. There is no shutdown hook that gracefully stops active hackbrowser runs, so on SIGTERM/SIGINT the worker subprocess (and its Chromium) may be left to die ungracefully — risking orphaned/zombie Chromium processes and a browser that never closed cleanly.
Current state
- Workers are spawned via
Bun.spawn (not detached). activeRuns holds one handle per session.
stopHackbrowser(sessionID) sends {type:"abort"} so the worker finishes the current page, closes the browser, and exits — the graceful path.
- No
process.on("SIGTERM"|"SIGINT") / shutdown handler iterates activeRuns to stop them.
Proposed
Add a shutdown hook that, on SIGTERM/SIGINT (and normal server exit), calls stopHackbrowser for every entry in activeRuns and waits briefly for graceful browser close before the process exits. Backstop: hard-kill any worker still alive after a short grace period (the launcher already schedules a proc.kill() after 10s on its own cleanup path).
Notes
- Genuine per-session teardown paths are already covered: Esc (
/abort) and session delete (Session.remove). This issue is only the process-level exit path.
Summary
Follow-up to the crawl-lifetime fix (crawl now runs in the background to its own
maxPages/empty queue instead of dying at turn-end). With that change, a background crawl can be alive when the server process exits. There is no shutdown hook that gracefully stops active hackbrowser runs, so on SIGTERM/SIGINT the worker subprocess (and its Chromium) may be left to die ungracefully — risking orphaned/zombie Chromium processes and a browser that never closed cleanly.Current state
Bun.spawn(not detached).activeRunsholds one handle per session.stopHackbrowser(sessionID)sends{type:"abort"}so the worker finishes the current page, closes the browser, and exits — the graceful path.process.on("SIGTERM"|"SIGINT")/ shutdown handler iteratesactiveRunsto stop them.Proposed
Add a shutdown hook that, on SIGTERM/SIGINT (and normal server exit), calls
stopHackbrowserfor every entry inactiveRunsand waits briefly for graceful browser close before the process exits. Backstop: hard-kill any worker still alive after a short grace period (the launcher already schedules aproc.kill()after 10s on its own cleanup path).Notes
/abort) and session delete (Session.remove). This issue is only the process-level exit path.