Skip to content

fix(runtime): never delete a browser profile lock a live process still holds - #40

Merged
volod-vana merged 1 commit into
mainfrom
volod/browser-profile-lock-owner
Sep 17, 2026
Merged

volod-vana merged 1 commit into
mainfrom
volod/browser-profile-lock-owner

Conversation

@volod-vana

Copy link
Copy Markdown
Member

Summary

launchPersistentContext removed SingletonLock unconditionally before every launch, on the assumption that the lock is always debris from a crash. That assumption is only half true:

  • after a crash, clearing it is correct and stays unchanged here
  • while another run is live, clearing it lets a second Chromium onto the same profile, which is exactly the corruption the lock exists to prevent

And when the removal does not take, the person sees a raw ProcessSingleton call log blaming Chromium, with no hint that another vana connect is the thing holding the profile.

This reads the lock's symlink target (<hostname>-<pid>, where the hostname itself may contain dashes, so only the final segment is the pid) and checks whether that pid is alive. Live holder: stop with a message naming the pid and how to clear it. Dead or unparseable: remove as stale, as before.

How this showed up

A vana connect linkedin --json --ipc run opened a headed Chrome for manual sign-in and parked at Complete any remaining verification, then click "Done". Nobody clicked it. Ninety-five minutes later it still held the profile, and every retry failed with the Chromium dump:

Failed to create a ProcessSingleton for your profile directory.
... Failed to create /Users/.../browser-profiles/linkedin-playwright/SingletonLock: File exists (17)

After this change that reads:

Another Vana browser session (pid 80496) is already using the profile at
/Users/.../browser-profiles/linkedin-playwright. That is usually an earlier
`vana connect` still waiting for you to finish signing in. Finish that
sign-in, or stop it with `kill 80496`, then try again.

Follow-up worth tracking separately

An interactive prompt under --json --ipc has no visible UI and no timeout, so it can block a profile indefinitely. Detecting the lock turns that into a clear message, but the underlying "interactive prompt in a non-interactive run" case still deserves a timeout.

Test plan

  • pnpm validate green (376 tests)
  • new unit tests: live pid, dead pid, missing lock, pid-less target
  • verified against real filesystem symlinks, not just mocks: live pid returns the pid, unreachable pid and absent lock both return null
  • cleared the real hung run on this machine and confirmed the profile and lock files were released

…l holds

The launcher treated every SingletonLock as stale and removed it before
starting Chromium. That is right after a crash and wrong while another run
is going: Chromium writes the lock precisely to keep two instances off one
profile, so clearing a live one invites the corruption it guards against.
When the delete does not take, the person gets a raw ProcessSingleton dump
that blames Chromium instead of naming the run actually holding the profile.

Read the lock's `<host>-<pid>` target, and when that pid is still alive stop
with a message that says which run holds the profile and how to clear it.
Stale locks are removed exactly as before.
@volod-vana volod-vana changed the title Never delete a browser profile lock a live process still holds fix(runtime): never delete a browser profile lock a live process still holds Sep 17, 2026
@volod-vana
volod-vana merged commit 385de5e into main Sep 17, 2026
6 of 7 checks passed
@volod-vana
volod-vana deleted the volod/browser-profile-lock-owner branch September 17, 2026 19:59
github-actions Bot pushed a commit that referenced this pull request Sep 17, 2026
## [0.24.0](v0.23.13...v0.24.0) (2026-09-17)

### Features

* **server:** refuse to silently collect into another identity's server ([#39](#39)) ([48cfb59](48cfb59))

### Bug Fixes

* **runtime:** never delete a browser profile lock a live process still holds ([#40](#40)) ([385de5e](385de5e))
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.24.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant