Skip to content

[Bug]: Hand-written newestVersion comparator misorders large prerelease identifiers #1119

Closed

Description

@jimhoyd

Runtime revision and environment

Bespoke-code audit of main 96543b7, Node 26.10.0. Reproduced directly against packages/core/src/package-files.ts:newestVersion, used by the add-on outdated report.

Minimal reproduction

newestVersion(['1.0.0-9007199254740993', '1.0.0-9007199254740992'])

Expected: '1.0.0-9007199254740993'.
Actual: '1.0.0-9007199254740992'.

Both inputs are accepted as valid by the checkout's installed semver package. Converting both numeric identifiers to Number loses the distinction; the sort treats them as equal and returns whichever is last.

Additional direct probes: newestVersion(['1.0.0-01','1.0.0-0']) chooses the invalid leading-zero prerelease, and newestVersion(['1.0.0+','1.0.0-alpha']) chooses the invalid empty-build-metadata version. Those invalid values may not come from a normal npm registry response; the large valid numeric identifier is the actionable ordering defect.

Relevant output

The checkout's semver.rsort selects 1.0.0-9007199254740993 for the first input, while the owned comparator selects the lower version. No package was installed/upgraded by the probe and no automatic downgrade is claimed.

Use semver's validated ordering (we already use semver as a development dependency; explicitly assess promoting it to runtime), or retain a narrowly correct comparator with precision-safe numeric identifier comparison and defined invalid-input behavior. Test input permutations, equal versions, build metadata and prereleases. This is a small general-purpose helper worth reconsidering on correctness evidence, not a reason for a new version abstraction.

Activity

  1. jimhoyd commented on Oct 1, 2026

    @jimhoyd
    CollaboratorAuthor

    Taking this: Issues [37f079]

  2. added
    bug
    in-progress
    on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugin-progress

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions