fix: clean stale lock files before launchPersistentContext - #320
fix: clean stale lock files before launchPersistentContext#320dyiapanis wants to merge 2 commits into
Conversation
When a Camoufox browser process crashes (SIGSEGV, OOM, unclean exit), Firefox leaves and files in the user data directory. These prevent a new browser from launching for the same profile — the launch appears to succeed but the browser immediately closes with 'persistent context closed' and no crash trace. Add that removes stale lock files before is called. Safe to call even if no lock files exist (no-op). Discovered while running concurrent browser instances for web extraction (Centipede plugin). After a SIGSEGV crash, the affected profile directory blocks all future launches for that userId until lock files are manually removed.
|
Thank you for your contribution to this project @dyiapanis.
so the main artifact is never removed ( Cheers! |
Per review feedback: - existsSync() follows symlinks; Firefox 'lock' is a symlink to a nonexistent target, so it never matched. Switch to lstatSync. - Parse the pid from the symlink target (<host>:+<pid>) and check process.kill(pid, 0) before removing — never delete a live process's lock (causes shared profile corruption). - Use rmSync(force) instead of existsSync+unlinkSync. - Make cleanup opt-in via clean_stale_locks: true in LaunchOptions.
|
Thanks for the review — all three points addressed in 5dc4d1e: 1. 2. Unconditional removal — Now parse the pid from the symlink target ( 3. Opt-in — Added Also switched from |
5dc4d1e to
d49985a
Compare
|
Hi @barjin — following up on this. All three points from your review were addressed in |
1 similar comment
|
Hi @barjin — following up on this. All three points from your review were addressed in |
When a Camoufox browser process crashes (SIGSEGV, OOM, unclean exit), Firefox leaves and files in the user data directory. These prevent a new browser from launching for the same profile — the launch appears to succeed but the browser immediately closes with 'persistent context closed' and no crash trace.
Add that removes stale lock files
before is called. Safe to call even if no
lock files exist (no-op).
Discovered while running concurrent browser instances for web extraction (Centipede plugin). After a SIGSEGV crash, the affected profile directory blocks all future launches for that userId until lock files are manually removed.