Repository navigation
fix(cli): stop browser --force from deleting chrome under running renders - #4901
Merged
Merged
Conversation
Contributor
Edit accuracy: accurate 1216 (base branch 1216), smooth 1048 of thoseThe gate passes. Quarantined, measured but not gated (1)
Unstable (1)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
hyperframes browser ensure --force, and the corrupt-archive retry, no longer delete the whole managed Chrome cache. A fresh chrome-headless-shell is downloaded into a private staging folder next to the cache and then swapped in by rename, replacing only its own version folder.Why
Both paths ran
rm -rf ~/.cache/hyperframes/chrome(the forced path throughclearBrowser()). The install lock only serializes installers, so any render or benchmark already using that binary lost chrome-headless-shell partway through its run.Repro on main: start a long render, then run
hyperframes browser ensure --forcein another shell. The render's browser binary disappears while the download runs.Related work
None.
browser clearkeeps deleting the whole cache on purpose: you only run it by hand.How
downloadBrowserinstalls withcacheDirset to~/.cache/hyperframes/.chrome-staging-<uuid>. That folder sits on the same filesystem as the cache, so the rename is atomic.moveStagedInstallIntoCachemoves the existing version folder aside, renames the staged one into place, then deletes the old copy. If the second rename fails, the old folder is moved back. On POSIX, a process already running the old binary keeps its inode.purgeStaleInstallis gone. Each install starts from a fresh staging folder, so @puppeteer/browsers never sees a half-extracted target folder. A stale partial extract in the cache gets replaced by the same rename.finally, so its staging folder (and, if it died between the two renames, the set-aside copy) would stay behind. The next install sweeps every.chrome-staging-*and.chrome-replaced-*folder while it holds the install lock, so none of them can belong to a live installer.browser clearsweeps them too.HYPERFRAMES_BROWSER_PATHhint as a failed download.--forcekeeps skipping the cache and system-Chrome shortcuts. It no longer purges other cached versions.Test plan
keeps a live reader's binary valid while a concurrent --force re-downloads itruns against the real filesystem. Partway through the second--forceinstall it reads the first install's binary path, then checks that the path holds the new build afterwards and that another version's folder survived. The fs mock gainedrenameSync, and the install mock now stages under thecacheDirit is given.restores the previous version when the staged install cannot be moved inpins the rollback and the hint;sweeps dirs leaked by a killed install on the next install and on clearpins both sweeps. Each goes red when its line is removed (rollback restore, sweep in the installer, sweep inclearBrowser, swap error outside the hint wrapper): 1 failed, 51 passed each time. 52 passed with everything in place.manager.tsreverted to main, the new test fails withENOENT ... chrome-headless-shellmid-install (2 failed, 48 passed). With the fix: 50 passed, exit 0.