GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: throw on bad version with correct error message by wraithgar · Pull Request #552 · npm/node-semver

Conversation

@wraithgar

@wraithgar wraithgar commented Apr 14, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

The parsing logic that is duplicated in SemVer's constructor was also removed. See #541 for previous discussions about not optimizing for invalid SemVer.

With this fix:

> semver.diff('foo', '1.2.3')
Uncaught TypeError: Invalid Version: foo

v7.4.0:

> semver.diff('foo', '1.2.3')
Uncaught TypeError: Invalid Version: null

503a4e52:

> semver.diff('foo', '1.2.3')
Uncaught TypeError: Cannot read properties of null (reading 'compare')

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@wraithgar
wraithgar requested a review from a team as a code owner April 14, 2023 16:10
@wraithgar
wraithgar requested a review from nlf April 14, 2023 16:10
@wraithgar wraithgar changed the title fix: throw on bad version fix: throw on bad version with correct error message Apr 14, 2023
@wraithgar

wraithgar commented Apr 14, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

This does reinstantiate, perhaps we need an unsafe parse (i.e. one that doesn't catch)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@wraithgar
wraithgar force-pushed the gar/parse-early branch from 16a021e to fd9578b Compare April 14, 2023 16:31
tjenkinson
tjenkinson reviewed Apr 14, 2023
View reviewed changes
Comment thread functions/parse.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@wraithgar
wraithgar force-pushed the gar/parse-early branch 2 times, most recently from c6b0ce1 to e0d7c01 Compare April 15, 2023 00:04
@wraithgar

wraithgar commented Apr 15, 2023

Copy link
Copy Markdown
Contributor Author

Arrays and objects still throw an ambiguous message but is it worth bringing in something like util.inspect?

> require('.').diff([], '1.3.2')
Uncaught TypeError: Invalid Version: 
> require('.').diff({}, '1.3.2')
Uncaught TypeError: Invalid Version: [object Object]

vs

throw new TypeError(`Invalid Version: ${require('util').inspect(version)}`)`
> require('.').diff([], '1.3.2')
Uncaught TypeError: Invalid Version: []
> require('.').diff({}, '1.3.2')
Uncaught TypeError: Invalid Version: {}
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tjenkinson

tjenkinson commented Apr 15, 2023

Copy link
Copy Markdown
Contributor

Given that code path should only be hit if you're doing something really wrong, I don't see any harm in making the error more readable with inspect

wraithgar reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@wraithgar
fix: throw on bad version
abdf690
@wraithgar
wraithgar force-pushed the gar/parse-early branch from e0d7c01 to abdf690 Compare April 15, 2023 19:31
@wraithgar wraithgar mentioned this pull request Apr 15, 2023
chore: release 7.5.0 #549
Merged
nlf
nlf approved these changes Apr 17, 2023
View reviewed changes
@wraithgar
wraithgar merged commit e219bb4 into main Apr 17, 2023
@wraithgar
wraithgar deleted the gar/parse-early branch April 17, 2023 17:00
@UNIDY2002

UNIDY2002 commented Apr 18, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

I don't see any harm in making the error more readable with inspect

Oops... This does break something.

I am using this library in a react-native project, and since RN does not run in a Node.js environment, its bundler might not recognize the "util" module, causing bundle failure.

I've just received a failure report, and haven't investigated into it.


Update: I installed util for polyfill, and now it is working fine.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tjenkinson

tjenkinson commented Apr 18, 2023

Copy link
Copy Markdown
Contributor

Ah I checked the node version support of it but didn’t realise this was also used in a browser 🙈

UNIDY2002 reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@snyk-bot snyk-bot mentioned this pull request May 16, 2023
[Snyk] Upgrade semver from 6.3.0 to 7.5.0 OutSystems/cordova-plugin-add-swift-support#3
Closed
@ms-bot ms-bot mentioned this pull request Jun 5, 2023
chore(deps): bump 🧳 semver to ^7.6.3 mobsuccess-devops/pmd-github-action#11
Closed
This was referenced Jul 31, 2023
Bump semver from 7.3.5 to 7.5.2 in /platform/ui ossrs/oryx#107
Closed
Bump semver from 7.3.5 to 7.5.4 in /platform/ui ossrs/oryx#111
Closed
Bump semver from 7.3.5 to 7.5.2 in /ui ossrs/oryx#116
Closed
This was referenced May 24, 2024
[Snyk] Upgrade semver from 7.3.7 to 7.6.0 NOUIY/npm-groovy-lint#71
Closed
[Snyk] Upgrade semver from 7.3.8 to 7.6.0 NOUIY/security-wg#55
Closed
@devcurt696 devcurt696 mentioned this pull request May 29, 2024
[Snyk] Upgrade semver from 7.0.0 to 7.6.1 devcurt696/resume-builder#77
Open
@NOUIY NOUIY mentioned this pull request May 30, 2024
[Snyk] Upgrade semver from 7.3.7 to 7.6.1 NOUIY/npm-groovy-lint#77
Closed
@fanibahar fanibahar mentioned this pull request May 30, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 fanibahar/juice-shop1#71
Open
@devcurt696 devcurt696 mentioned this pull request May 31, 2024
[Snyk] Upgrade semver from 7.0.0 to 7.6.2 devcurt696/resume-builder#78
Open
@NOUIY NOUIY mentioned this pull request May 31, 2024
[Snyk] Upgrade semver from 7.3.7 to 7.6.2 NOUIY/npm-groovy-lint#78
Closed
@Mhmonicox Mhmonicox mentioned this pull request Jun 1, 2024
[Snyk] Upgrade semver from 7.3.6 to 7.6.2 Mhmonicox/actions-setup-cmake#35
Open
@Haricthered Haricthered mentioned this pull request Jun 7, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 Haricthered/juice-shop#5
Open
@AndrewSnyk AndrewSnyk mentioned this pull request Jun 8, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 AndrewSnyk/juice-shop#5
Merged
@jessicazhanggg jessicazhanggg mentioned this pull request Jun 13, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 jessicazhanggg/juice-shop#6
Open
@monjie110 monjie110 mentioned this pull request Jun 22, 2024
[Snyk] Upgrade semver from 7.3.4 to 7.6.2 monjie110/vscode-go#4
Open
@Kavinpg96 Kavinpg96 mentioned this pull request Jun 25, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 Kavinpg96/nodejs.org#5
Open
@dulumina dulumina mentioned this pull request Jul 11, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 dulumina/WBOT#2
Open
This was referenced Jul 16, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 Exhorder6/addons-linter#31
Closed
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 terrorizer1980/addons-linter#35
Closed
@Z-byte-prog Z-byte-prog mentioned this pull request Jul 17, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 Z-byte-prog/docs#1243
Closed
@safiaminnn safiaminnn mentioned this pull request Jul 21, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 safiaminnn/juice-shop#5
Open
@YoYBaBy YoYBaBy mentioned this pull request Jul 23, 2024
[Snyk] Upgrade semver from 7.3.2 to 7.6.2 YoYBaBy/nodejs.org#274
Open
@koishichito koishichito mentioned this pull request Jul 24, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 koishichito/juice-shop#5
Open
@KobayashiMasaomi KobayashiMasaomi mentioned this pull request Jul 25, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 KobayashiMasaomi/juice-shop#10
Open
@q1blue q1blue mentioned this pull request Jul 28, 2024
[Snyk] Upgrade semver from 5.7.2 to 7.6.2 https-quantumblockchainai-atlassian-net/botframework-sdk#1
Open
@otmaneEH otmaneEH mentioned this pull request Jul 30, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 otmaneEH/docs#4
Open
@annkornienko annkornienko mentioned this pull request Jul 30, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 Simpplr/serverless-plugin-include-dependencies#12
Closed
@hkleungai hkleungai mentioned this pull request Aug 5, 2025
feat(semver): identifierBase for inc() & throwErrors for parse() & jsdoc DefinitelyTyped/DefinitelyTyped#73409
Merged
7 tasks done
@coderabbitai coderabbitai Bot mentioned this pull request May 8, 2026
fix: 修复条件式 hook 调用导致的 "Rendered fewer hooks than expected" 错误 claude-code-best/claude-code#435
Merged
1 task
@coderabbitai coderabbitai Bot mentioned this pull request Jul 28, 2026
feat(stagewise): improve auto-update flow and release notes stagewise-io/stagewise#1494
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

2 more reviewers
@tjenkinson tjenkinson tjenkinson left review comments
@nlf nlf nlf approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@wraithgar @tjenkinson @UNIDY2002 @nlf
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.