fix: isolate headless Chrome profiles on macOS - #322
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6b3123dd6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| try { Directory.Delete(Path, recursive: true); } | ||
| catch { /* temporary profile cleanup is best effort */ } |
There was a problem hiding this comment.
Wait for timed-out Chrome processes before deleting profiles
When a Chrome invocation times out on Windows, both RunBinary and RunChromeCapture call Kill(true) and return without waiting for the process tree to exit. Dispose therefore immediately attempts this deletion while Chrome can still hold profile files open; the exception is swallowed and the unique officecli-chrome-* directory is permanently left behind, potentially leaking substantial temporary data after repeated render timeouts. Wait for termination or retry cleanup before abandoning the directory.
Useful? React with 👍 / 👎.
Summary
Every direct Chromium rendering path now launches with a unique temporary
--user-data-dir; macOS additionally receives--use-mock-keychain.This prevents headless document rendering from contending with the user's Chrome profile or attempting to create Chrome Safe Storage in the user login keychain, which can display a system Keychain reset prompt when HOME is isolated.
Coverage
The shared isolation helper is used by DOM dumping, regular screenshots, sized screenshots, and clipped screenshots. Temporary profiles are removed after the browser exits.
Validation
dotnetis not installed on the submitting macOS machine, so this needs the repository's .NET CI build.