-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Npm: fetch latest version from registry.npmjs.org #20734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
livecheck's `Npm` strategy is currently broken because the npmjs.com website is behind Cloudflare and upstream may have have changed their security settings, as we're now seeing 403 (Forbidden) responses. This modifies the strategy to check the latest version from registry.npmjs.org instead, which doesn't seem to have the same problem. Besides fixing the strategy, this change has some side benefits: * Checking the `latest` endpoint ensures that livecheck is tracking the version that's marked as "latest" on npm. In testing this, I saw one formula (`yaml-language-server`) where the version we're using is marked as "next" on npm and it's newer than "latest". We can revisit this approach if it becomes a problem in practice but it seems like a beneficial change on the surface. * We have some formulae where the npm package has an excessive number of previous versions (hundreds or thousands) and the `Npm` strategy was having to download more data than we need just to find the latest version. The responses from the `latest` endpoint involve much less data transfer, so these checks seem pretty snappy now (granted, I can't do a real comparison as the current `Npm` strategy is broken).
fa90846 to
eb9ac05
Compare
This was referenced Sep 20, 2025
nandahkrishna
approved these changes
Sep 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, thanks @samford!
6 tasks
MikeMcQuaid
approved these changes
Sep 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
chenrui333
approved these changes
Sep 20, 2025
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.
brew stylewith your changes locally?brew typecheckwith your changes locally?brew testswith your changes locally?livecheck's
Npmstrategy is currently broken because the npmjs.com website is behind Cloudflare and upstream may have have changed their security settings, as we're now seeing 403 (Forbidden) responses. This modifies the strategy to check the latest version from registry.npmjs.org instead, which doesn't seem to have the same problem.Besides fixing the strategy, this change has some side benefits:
latestendpoint ensures that livecheck is tracking the version that's marked as "latest" on npm. In testing this, I saw one formula (yaml-language-server) where the version we're using is marked as "next" on npm and it's newer than "latest". We can revisit this approach if it becomes a problem in practice but it seems like a beneficial change on the surface.Npmstrategy was having to download more data than we need just to find the latest version. The responses from thelatestendpoint involve much less data transfer, so these checks seem pretty snappy now (granted, I can't do a real comparison as the currentNpmstrategy is broken).I tested this across all the existing formulae that use the
Npmstrategy and the only issue I saw was withgemini-cli, where the version from thelatestendpoint was temporarily a dev version instead of the version that was reported as "latest" on npmjs.com. registry.npmjs.org is now back to reporting the correct latest version, so this may be a package-specific issue relating to how Google publishes new versions.It's something we should keep an eye on but if it only affects a small number of packages over time (e.g., fewer than five), we can simply address those by adding a
livecheckblock in the formula to check a different source (noting the issue in a comment). If it ends up being a regularly-occurring and widespread issue, then we'll have to go back to the drawing board. This seems to work as expected for all the other packages, so I think we're okay moving forward with this for now.