fix(cli): call defaultRegistryDirectory() when resolving the cache file - #454
Merged
Devin Rousso (dcrousso) merged 1 commit intoAug 24, 2026
Merged
Conversation
Contributor
Author
|
and command if using cache fast to ~370ms all command. |
`registry.defaultRegistryDirectory` became a function upstream in microsoft/playwright#41942 and arrived here with the roll to 1.63.0-alpha-2026-08-05. `cacheFile()` still used it as a string, so `path.join()` threw, `readCache()`/`writeCache()` swallowed the TypeError, and the update check was never cached: every single CLI invocation fetched the npm registry and re-ran the installed-skill check. Locally that is ~480ms per command instead of ~125ms. Tests always set PLAYWRIGHT_CLI_INSTALLATION_FOR_TEST, so the default branch was never exercised. Add a regression test that points HOME at a temp directory and asserts the cache file is written. Also hoist `cacheFile()` out of the try blocks so only I/O and parse failures are swallowed there, instead of masking a path-computation bug as "no cache".
Contributor
Author
|
@microsoft-github-policy-service agree |
Mert Can Altin (mertcanaltin)
force-pushed
the
fix-update-check-cache
branch
from
August 23, 2026 12:03
70a54e6 to
123825b
Compare
Devin Rousso (dcrousso)
approved these changes
Aug 24, 2026
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.
I am interested in the
playwright-cliversion command because this version control code worked once one day and set a note for update control, but this control does not write the version to the document and always goes to controlI called the
defaultRegistryDirectory()method after starting the writer for the doc, and it didn’t go to the web for version control; it read the cache doc.What is broken
The update check is meant to run at most once a day, cached in
cli-update-check.json. That cache file is never written, so every CLI invocation hitsregistry.npmjs.organd re-runs the installed-skill check.Root cause
registry.defaultRegistryDirectorybecame a function in microsoft/playwright#41942 (2026-07-23) and reached this repo with the roll to1.63.0-alpha-2026-08-05(#442).cacheFile()still used it as a string:path.join()throws aTypeError, whichreadCache()andwriteCache()swallow in their barecatch {}— so the failure reads as "no cache yet" and the check is always stale.Impact
Measured with
--version, before → after:The second row is the 1500ms
AbortControllertimeout infetchLatestVersion(), paid on every command.Why CI did not catch it
runCli()always setsPLAYWRIGHT_CLI_INSTALLATION_FOR_TEST, so the||short-circuits and the broken branch never runs. The added test pointsHOMEat a temp directory, leaves that variable empty, and asserts the cache file is written.Changes
registry.defaultRegistryDirectory()cacheFile()out of thetryblocks so only I/O and parse errors are swallowed there, instead of masking a path-computation bug as "no cache" (happy to drop this if you prefer the fix alone)asist: Claude opus 5