Prefer stable versions when resolving range (#774)#800
Open
AMDphreak wants to merge 1 commit intonodejs:mainfrom
Open
Prefer stable versions when resolving range (#774)#800AMDphreak wants to merge 1 commit intonodejs:mainfrom
AMDphreak wants to merge 1 commit intonodejs:mainfrom
Conversation
889ffe4 to
b08a894
Compare
- Update resolveDescriptor to prefer stable matching versions unless the range explicitly targets prereleases. - Add isPrereleaseRange helper in semverUtils.
b08a894 to
9be199f
Compare
MikeMcC399
suggested changes
Mar 4, 2026
Contributor
MikeMcC399
left a comment
There was a problem hiding this comment.
There are a lot of unrelated formatting changes in this PR, which means that it fails linting, and is difficult to review.
The following should fix the formatting:
corepack yarn lint --fixPlease reformat the text in the original post which includes \n characters instead of actual newlines.
This repo uses release-please so it would need a commit message like fix:
I'm not a maintainer, so I can't approve or process this PR further. It would however be good for issue #774 to be fixed, as it has caused me problems in the past.
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.
This PR fixes #774 by ensuring that Corepack prefers the latest stable version over newer prereleases when resolving a range (like * or latest), unless a prerelease is explicitly requested.\n\n### Problem\nWhen multiple versions match a range, Corepack currently just sorts them with semver.rcompare. Since prereleases (e.g., 11.0.0-dev...) are considered higher than the latest stable (e.g., 10.4.1), Corepack incorrectly selects the prerelease. This causes issues when prereleases have breaking changes in binary paths or behavior.\n\n### Fix\nIn
esolveDescriptor, we now split matching versions into stable and prerelease sets. We prefer the highest stable version if one exists, and only fallback to prereleases if the requested range specifically targets them (checked via isPrereleaseRange helper).