Repository navigation
fix(shared): compare numeric prerelease identifiers without precision loss - #29733
romil-bijarnia wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Numeric comparison and regression tests packages/shared/src/semver.ts, packages/shared/src/semver.test.ts |
The comparison removes leading zeroes, then compares numeric identifiers by length and lexical order. Tests check large values in both comparison directions and self-comparison. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: yashranaway
Merge Risk: 
Minimal · up to 5c8b0
-
The numeric prerelease comparison fix is mergeable within the reviewed scope.
Pre-merge checks: 
4
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
CodeRabbit Verify
- Run CodeRabbit Verify to test the changes in this pull request.
|
Thanks, @romil-bijarnia, for the earlier fix and regression coverage. Closing this as a duplicate of #32169 by @luke2x, which also fixes numeric prerelease precision. This PR has had no author update for over a week, and main has changed the affected files since its base. |
Problem
Numeric prerelease identifiers are converted to JavaScript Numbers before comparison. Distinct values such as
9007199254740992and9007199254740993then compare as equal. Very long identifiers overflow to Infinity, so even comparing a version with itself returns NaN.Change
Compare normalized digit strings by length, then lexically when their lengths match. This gives numeric order without rounding or overflow and preserves the parser's existing tolerance of leading zeros.
Scope and approval
This is a small, focused comparator bug fix under CONTRIBUTING.md's obvious-bug exception. Searches for numeric prerelease ordering, precision, overflow and the comparator found no open PR covering this failure. #28836 fixes nonnumeric ASCII ordering in the same helper; it does not change numeric comparisons.
Verification
macOS, Node 26.12.1, base
71646e031a6d.0to-1; equal 310-digit identifiers change fromNaNto0; a 310-digit value versus a larger 311-digit value changes fromNaNto-1.vp run check:changed origin/main --concurrency 2passed formatting, lint, both Knip checks, typechecks for 34 affected packages, and 11 tests in two selected files.This is an edge-case parser correction. No live provider release or update UI was exercised.