Repository navigation
Conversation
The lock is always a dangling symlink to <hostname>-<pid>, so testing for the link alone reads every crashed or rebooted-away browser as still running, and the migration's close-the-browser prompt repeats forever. Follow Chromium and let the pid decide. Fixes #6866 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A pid the kernel has handed on to some unrelated process would otherwise keep reading as an open profile, which is the same loop a dead pid caused. What the process holds open answers that better than what it is called: a browser keeps dozens of files inside the profile it owns, whatever its binary is named. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes stale Chromium locks blocking the Copy URL migration indefinitely.
Changes:
- Determines lock ownership using PID, open files, and executable name.
- Adds coverage for stale, reused, and profile-owning PIDs.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
migrations/1786643346.sh |
Improves Chromium profile lock detection. |
test/shell.d/copy-url-shortcut-migration-test.sh |
Tests live and stale lock scenarios. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # running holds this test's output pipe open long after the run. | ||
| holder_pid="" | ||
| cleanup() { | ||
| kill $browser_pid ${holder_pid:-} 2>/dev/null |
Only a pid that is demonstrably gone, or demonstrably not a browser, clears the way now. One that exists but answers nothing about itself — a process another user owns, or one that hides its files and binary — kept the repair from running under a browser we simply failed to recognize. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
migrations/1786643346.sh:151
readlinkreturns a non-zero status if any descriptor from the expanded glob closes before it is inspected. The|| fds=""branch then discards paths successfully read from the remaining descriptors, so a busy browser with an unrecognized executable name can be mistaken for a reused PID even while it still holds profile files open. Preserve partial output (or inspect descriptors individually) so descriptor churn cannot bypass the open-profile guard.
fds=$(readlink -- /proc/$pid/fd/* 2>/dev/null) || fds=""
The prompt loop sits inside omarchy-update, so a profile that reads as open whatever the user does hangs the update itself, with no way past it. Three rounds is someone closing windows; past that, name the profile, say how to clear a leftover lock, and leave the repair to a later run. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
migrations/1786643346.sh:151
readlinkexits nonzero if even one descriptor disappears after glob expansion, despite printing targets for the descriptors it did read. Resettingfdson that status discards all successful evidence, so normal FD churn can make a live browser with an unrecognized executable look closed and allow the repair while it owns the profile. Preserve the partial output while makingreadlinkfailure nonfatal.
fds=$(readlink -- /proc/$pid/fd/* 2>/dev/null) || fds=""
Someone closing four browsers one prompt at a time is making progress every time, and a budget meant for a profile that never closes was cutting them off at the fourth. Start the count over whenever the wait moves on to a different profile. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
migrations/1786643346.sh:151
readlinkreturns nonzero if any descriptor disappears after glob expansion, and this||then discards every successfully read target. Chromium processes churn descriptors, so an unrecognized browser can be misclassified as a reused PID even when other descriptors still point into the profile, allowing the repair while it is open. Preserve partial output and only use an empty result when nothing was readable.
fds=$(readlink -- /proc/$pid/fd/* 2>/dev/null) || fds=""
A browser that crashed while its parent was not watching keeps its /proc entry with no files and no binary behind it, which the unreadable-process rule took for a browser too secretive to identify — and held the repair on a profile nothing has open. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (2)
migrations/1786643346.sh:157
readlinkreturns a failure status if any FD disappears between glob expansion and inspection. The|| fds=""branch then discards targets successfully read from the other descriptors, so an active browser with a nonstandard executable name can be misclassified as a reused PID during normal FD churn. Preserve partial output and let the executable check handle the case where nothing was readable.
fds=$(readlink -- /proc/$pid/fd/* 2>/dev/null) || fds=""
test/shell.d/copy-url-shortcut-migration-test.sh:142
- The fixed delay does not establish that the background process has opened the profile before the migration inspects it. On a busy runner the process can still be starting, causing the migration to classify the PID as unrelated and making this test fail nondeterministically. Poll the specific inherited descriptor and fail explicitly if the holder never becomes ready.
sleep 0.2
Reviewers keep asking to drop the name check once the file scan comes back clean, which would repair under any browser whose files this cannot see. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
migrations/1786643346.sh:157
- If any descriptor closes between glob expansion and
readlink, GNUreadlinkreturns nonzero even though it printed the other valid targets; the|| fds=""then discards all of that evidence. An active browser with an unrecognized executable name can consequently be classified as closed and have its Preferences repaired while running. Preserve successful outputs while tolerating individual disappearing descriptors.
fds=$(readlink -- /proc/$pid/fd/* 2>/dev/null) || fds=""
readlink exits non-zero when any one of its arguments fails, while still printing the rest. A browser opening and closing descriptors between the glob and the read made `|| fds=""` throw away every descriptor inside the profile, so a browser whose binary the name list does not know read as closed and the repair ran under it. Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed and tested on a fresh Omarchy worker. The fix works, and I pushed one small correction to it, but the branch no longer merges: What was checked. A reproduction of #6866 of my own: a profile with a pending Copy URL repair, a Pushed: aa9724d. Second opinion. Codex Medium reviewed it and found the
The new tests also report a pass when the unreadable-pid and zombie cases cannot be set up, and a pass there is really a skip. Waiting on the author, to resolve the conflict with |
Fold in PR omacom#6872: a lock holds only while its pid still owns the profile (open files, browser name, zombies), and the prompt gives up after three tries per profile so omarchy-update cannot hang. Keep a live SingletonSocket connect() as the fallback when that pid looks dead or reused. Port those cases into copy-url-migration-test.sh instead of restoring the retired shortcut test.
|
Trimmed the test changes so this merges with
The migration change is untouched. On a disposable worker,
🤖 Reviewed by Claude Opus 5.5 in Claude Code, second opinion Codex XHigh. |
[Medium impact] The change reaches the Copy URL repair in the update workflow. The PR appears safe to merge, with a non-blocking request for tests covering the new lock checks and prompt limit. Findings
SummaryThe migration now checks whether a Chromium lock still names a running browser instead of treating every leftover link as an open profile.
Acknowledgments: Reviews (1) · Last reviewed commit: "Drop the test changes for the retired Co..." · Reviewed by Greptile |
| # A lock another machine wrote (or one that doesn't parse) says nothing | ||
| # from here, so leave it counting as open rather than repair under a | ||
| # browser we cannot see. | ||
| [[ $host == "$(uname -n)" && $pid =~ ^[0-9]+$ ]] || return 0 |
There was a problem hiding this comment.
Every simulated lock names test-host-1234, so the existing tests return at this hostname check without reaching the new PID checks. Successful confirmations also close the browser immediately, leaving the three-prompt limit untested.
Add cases for a dead PID, a live owner, a reused non-browser PID, and the prompt limit resetting when the waiting profile changes. Otherwise, both fixes can regress while the tests still pass.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
One thing #14457 has that this branch doesn't: an #14457's |
|
Re-verified at 9d3ff58, merged into current What was checked. My own reproduction of #6866 ran with a
On the merged tree, the dead, reused and zombie pids and the Brave Origin rerun all repair without a prompt. A live holder and a foreign lock prompt three times, exit 1 and leave Second opinion. Codex Medium reviewed the merged tree and found nothing wrong with it, including the sourcing from Competing fix: #14457. It carries this PR's lock check verbatim and adds three things:
The two reviewers disagree on which fix should win. Codex Medium picks #14457 for the On the Greptile note that the new branches have no tests: those cases were dropped in 9d3ff58, following |
The Copy URL migration asks for browser windows to be closed, then waits for the affected profile to actually close. It decided a profile was open by testing for a
SingletonLocklink — but Chromium's lock is always a dangling symlink: it points at<hostname>-<pid>, never at a file. So the test only ever meant "a lock link exists", which a crash or a reboot leaves behind indefinitely. Pressing Continue changed nothing, and the prompt repeated forever. Removing the link by hand was the only way through, as #6866 reports.The lock now answers the question it was always meant to answer: is a browser still holding this profile. The pid encoded in the link decides, the way Chromium decides about its own lock before clearing it. A lock another machine wrote still counts as open — that one is genuinely unreadable from here, and deferring the repair is the harmless direction to be wrong in.
A dead pid gets handed on to whatever starts next, so a live pid alone isn't enough either. What the process holds open settles it: a browser keeps dozens of files inside the profile it owns — leveldb locks, the login database, the quota manager — and that identifies the owner without depending on what its binary is called, which is what the Edge and Brave and Vivaldi naming would otherwise turn into a guessing game. The executable name stays as a fallback, again erring toward deferring.
Only a pid that is demonstrably gone, or demonstrably not a browser, clears the way. One that exists but answers nothing about itself — another user's process, or one that hides its files and binary — counts as open, so a browser this migration fails to recognize costs a deferred repair rather than a silently reverted one.
The prompt loop is now bounded, which matters more than the detection itself: it runs inside
omarchy-update, where waiting forever hangs the update with nothing the user can do. Three rounds with no movement on the profile it is waiting for, and it names that profile, says which links to delete, and leaves the repair to a later run. Closing profiles one at a time still counts as progress, so working through four browsers does not exhaust a budget meant for one that never closes.I verified this against a real Chromium rather than only the fixtures: a headless browser on a scratch profile writes
mbu-r9-3000350into the lock and holds 27 files inside the profile, the migration defers while it runs,kill -9leaves the lock exactly as the report describes, and the migration then repairs through it and completes.Fixes #6866
— 🤖 Claude, posting on behalf of @dhh