Skip to content

fix(core): refresh stale @latest npm package cache on load#35777

Open
yudgnahk wants to merge 7 commits into
anomalyco:devfrom
yudgnahk:npm-cache-refresh
Open

fix(core): refresh stale @latest npm package cache on load#35777
yudgnahk wants to merge 7 commits into
anomalyco:devfrom
yudgnahk:npm-cache-refresh

Conversation

@yudgnahk

@yudgnahk yudgnahk commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #25293

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Npm.add short-circuited when node_modules/{name} existed, so plugins configured as @latest never picked up newer registry releases.

For mutable registry specs (@latest, ranges, bare names), compare the installed version against dist-tags.latest before returning the cache. If the registry is newer, remove package-lock.json and reify. Pinned versions and file/git specs skip the registry check. Registry failures/timeouts keep the cached install.

Also adds AddOptions.refresh so explicit install paths can force a cache bypass.

How did you verify your code works?

cd packages/core
bun typecheck
bun test test/npm.test.ts

Seeded ms@2.0.0 in an isolated cache (XDG_CACHE_HOME), then confirmed Npm.add("ms@latest") and resolvePluginTarget updated to registry 2.1.3.

Screenshots / recordings

N/A (core only)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Plugins configured with @latest were pinned to whatever version was
installed first because Npm.add short-circuited on node_modules without
checking the registry. Compare installed semver against dist-tags.latest
for mutable registry specs and reify when newer; pinned and file/git
specs are unchanged. Offline registry failures keep the cached install.

Fixes anomalyco#25293
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. contributor and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@yudgnahk
yudgnahk marked this pull request as ready for review July 7, 2026 18:59
@yudgnahk

Copy link
Copy Markdown
Contributor Author

@rekram1-node could you please help me review this PR? Thank you!

@tobwen

tobwen commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

@yudgnahk I did a follow-up on this in #37688

I think it would be fair if you incorporated my changes so that you're listed in the credits. After all, my work is based on yours.

But to be honest: I don't think the team will be interested in our corrections.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin @latest cache can stay pinned to stale npm version

2 participants