fix(core): refresh stale plugin cache#37688
Open
tobwen wants to merge 1 commit into
Open
Conversation
Plugins declared with a floating `@latest` spec were pinned to the first installed version: `Npm.add` short-circuited on a directory-existence check and never re-resolved the dist-tag. For mutable registry specs (`@latest`, ranges, bare names), compare the cached version against registry `dist-tags.latest` and `reify` when newer. Pinned versions, aliases, and file/git/remote specs skip the check. If the refresh `reify` then fails (transient registry/network error, or lock contention), fall back to the still-present cached install instead of breaking the plugin load. `AddOptions.refresh` forces a re-resolve for pinned/file specs.
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Related PR Found:
This PR is directly related. According to the PR description, #37688 builds on #35777 by addressing the same issue (stale |
6 tasks
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.
Issue for this PR
Closes #25293
Type of change
What does this PR do?
Plugins declared with a floating
@latestspec were pinned to the first installed version:Npm.addshort-circuited on a directory-existence check (afs.existsSafe) and never re-resolved the dist-tag, so newer registry releases were silently ignored.For mutable registry specs (
@latest, ranges, bare names),Npm.addnow reads the cachedpackage.jsonversion, fetchesdist-tags.latestfrom the registry, and re-runsarborist.reify()when the registry version is newer. Pinned versions, aliases, and file/git/remote specs skip the check.AddOptions.refreshforces a re-resolve for pinned/file specs.The registry fetch has a 5s
AbortSignal.timeoutand collapses any failure toundefined, so a down registry keeps the cached install. If the refreshreifyitself fails (transient network error or lock contention),addfalls back to the still-present cached entry point instead of throwing, so a refresh attempt does not break the plugin load.This builds on #35777, which attempted the same
dist-tags.latestcomparison but threwInstallFailedErrorwhen the refreshreifyfailed, breaking the plugin load despite a working cache on disk. This PR wraps that refreshreifyinEffect.catchto fall back to the cache, and adds thealiasspec type to the immutable list.How did you verify your code works?
bun typecheck(turbo, 30 packages): clean.packages/corefull suite: 1083 pass, including new tests forisMutableRegistrySpec(mutable, immutable,alias, invalid spec),shouldRefreshInstall(newer, equal, older, prerelease, missing, non-semver), a forced refresh that updates a cached file spec, and a fallback that returns the cached install when a@latestreifyfails.oxlinton changed files: 0 errors.Screenshots / recordings
N/A (core only).
Checklist