Skip to content

fix(browser): reap Chrome and profiles orphaned by killed runs - #811

Merged
casoon merged 1 commit into
mainfrom
fix/orphaned-chrome
Oct 29, 2026
Merged

casoon merged 1 commit into
mainfrom
fix/orphaned-chrome

Conversation

@casoon

@casoon casoon commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Headless Chrome instances kept running after auditmysite was killed from outside (SIGKILL, a supervisor or test timeout): close() and Drop never run in that case, so Chrome ended up under init and its auditmysite-chrome-* profile stayed in the temp dir. Locally that was one live orphan and 1324 profiles (3.3 GB) after four days of test and mutation runs.

Browser start (src/browser/manager.rs): before the first launch of a process, every auditmysite-chrome-<pid>-… profile whose owning process is gone is removed. The Chrome still holding it (pid from Chrome's own SingletonLock) is ended first with TERM, then KILL — only if its command line runs on that very profile, so a reused pid is never killed. Live owners keep their profiles; foreign directories are not touched. Unix only; a no-op elsewhere.

mutation-check.py: each test runs in its own process group; a timeout or Ctrl-C kills the group instead of only cargo, which had left the test binary and its Chrome running.

Verified:

  • unit tests: orphan reaped and its stand-in Chrome ended, own and foreign dirs kept, a reused lock pid survives
  • end to end: audit started, SIGKILLed once Chrome was up (orphan and profile left behind), second audit logged Removed 1 orphaned browser profile(s), the orphan was gone and the audit wrote its report
  • passes() timeout kills grandchildren of the test command
  • clippy -D warnings with and without features

A run ended by SIGKILL, a supervisor or a test timeout never reaches
close() or Drop, so its headless Chrome kept running under init and its
auditmysite-chrome-* profile stayed in the temp dir (1324 profiles, 3.3 GB
here after four days). Before the first launch, a profile whose owning
process is gone is removed; the Chrome named in its SingletonLock is ended
first, but only if its command line runs on that profile.

mutation-check.py runs each test in its own process group and kills the
group on a timeout or Ctrl-C, instead of only cargo.
@casoon
casoon merged commit e6f26e3 into main Oct 29, 2026
14 checks passed
@casoon
casoon deleted the fix/orphaned-chrome branch October 29, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant