Skip to content
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

[BUG] semver.satisfies("9007199254740991.9007199254740991.9007199254740991--", "~9007199254740991.9007199254740991.9007199254740991-1") returns false #393

Closed
martijnhoekstra opened this issue Jul 26, 2021 · 1 comment · Fixed by #450

Comments

@martijnhoekstra
Copy link

What / Why

semver.satisfies("9007199254740991.9007199254740991.9007199254740991--", "~9007199254740991.9007199254740991.9007199254740991-1")

returns false whereas I'd expect it to return true. Note that 9007199254740991 is max safe int, and replacing all those with 1 makes it return true.

When

  • every time I call the method with those parameters.

Where

  • npm/node-semver

How

Current Behavior

  • call semver.satisfies("9007199254740991.9007199254740991.9007199254740991--", "~9007199254740991.9007199254740991.9007199254740991-1")
  • false is returned

Steps to Reproduce

  • call semver.satisfies("9007199254740991.9007199254740991.9007199254740991--", "~9007199254740991.9007199254740991.9007199254740991-1")

Expected Behavior

  • true is returned

Who

  • I don't know

References

  • I don't know
@lukekarrys
Copy link
Member

lukekarrys commented Apr 10, 2022

By design the maximum value for any semver component is Number.MAX_SAFE_INTEGER. So 9007199254740991.9007199254740991.9007199254740991 is a valid version. But in order to create the range ~9007199254740991.9007199254740991.900719925474099 it has to increment the minor component which results in an invalid version being created in order to create the range:

> new semver.Range('~9007199254740991.9007199254740991.900719925474099')
Uncaught TypeError: Invalid minor version

semver.satisfies catches any error and returns false which might seem weird in this case since the range isn't obviously invalid, but that's what it does for all cases:

> semver.satisfies("1.0.0", "hello")
false

I created #450 to add an explicit test for this behavior, but I don't see any way around fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants