GeezerVison is showing github.com — yarn 1.x.x invalid url with node 18.17.0 VS 18.16.1 · Issue #48855 · nodejs/node
yarn 1.x.x invalid url with node 18.17.0 VS 18.16.1 #48855DescriptionVersion
18.17.0
Platform
Mac OS (aarm64 & intel)
Subsystem
No response
What steps will reproduce the bug?
Using node 18.17.0 and installing yarn 1.x.x will cause this error.
How often does it reproduce? Is there a required condition?
- Every time after installing 18.17.0 from 18.16.1. So far, this issue is specific to a monorepo being used.
- I'm having a hard time replicating it on init projects that use the npm registry. The project with the issue uses a artifactory jfrog registry which points to a couple other internal artifactory registries.
Other tips to replicating this issue:
- If you are swapping node from a minor version make sure to reset your yarn cache to replicate the issue 100% of the time. IE
yarn cache clear. Project level cache should be enough.
Example commands
nvm install 18.17.0; nvm use 18.17.0; npm i -g yarn; yarn cache clean; yarn;
What is the expected behavior? Why is that the expected behavior?
yarn should install dependencies and resolve those urls.
What do you see instead?
Error and unexpected error has occurred "Invalid Url".
Additional information
If this is an expected behavior change 18.16 - 18.17.0 (breaking yarn package manager on 1.x.x) we can close this issue.
Yarn 1.x.x is still used in many projects so this may affect a bunch of users.
Temp workarounds
- Stay on Node 18.16 and lock the version. IE with .nvrmc or _node-version change it from
18 to 18.16
Possibly related URL issues:
Reacted by Gerrick Bivins, Tim Dettrick, liaoyu and Steven Activityanonrig commented on Jul 20, 2023 Can you share the URL causing this error? cc @nodejs/url FrederickEngelhardt commented on Jul 20, 2023 verbose 0.688693792 TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:405:5)
at Url.parse (node:url:445:17)
at urlParse (node:url:167:13)
at GitResolver.isVersion (/Users/<path>.yarn/releases/yarn-1.22.19.js:38701:21)
at getExoticResolver (/Users/<path>.yarn/releases/yarn-1.22.19.js:29731:18)
at /Users/<path>.yarn/releases/yarn-1.22.19.js:38152:78
at Generator.next (<anonymous>)
at step (/Users/<path>.yarn/releases/yarn-1.22.19.js:310:30)
at /Users/<path>.yarn/releases/yarn-1.22.19.js:321:13
error An unexpected error occurred: "Invalid URL".
info If you think this is a bug, please open a bug report with the information provided in "/Users/<path>yarn-error.log".
aduh95 commented on Jul 20, 2023 Reacted by Frederick Engelhardt aduh95 commented on Jul 20, 2023 The throw is located at
|
if (this.hostname === '' || forbiddenHostChars.test(this.hostname)) { |
|
throw new ERR_INVALID_URL(url); |
|
} |
The hostname is set at
|
this.hostname = toASCII(this.hostname, true); |
And toASCII is imported from internal/idna:
|
const { toASCII } = require('internal/idna'); |
Which itself reexports it from internal/url:
|
const { domainToASCII, domainToUnicode } = require('internal/url'); |
|
module.exports = { toASCII: domainToASCII, toUnicode: domainToUnicode }; |
The list of commits that have touched internal/url since v18.16.0 is not small:
https://github.com/nodejs/node/commits/a39b8a2a3e8414c8a54650bdfe4a46998282d88a/lib/internal/url.js
/cc @nodejs/url akkunchoi commented on Jul 21, 2023 $ node --version && node -e "console.log(require('node:url').parse('x://0.0,1.1/').host)"
v18.16.1
0.0,1.1
$ node --version && node -e "console.log(require('node:url').parse('x://0.0,1.1/').host)"
v20.5.0
0.0,1.1
$ node --version && node -e "console.log(require('node:url').parse('x://0.0,1.1/').host)"
v18.17.0
node:url:445
throw new ERR_INVALID_URL(url);
^
TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:405:5)
at Url.parse (node:url:445:17)
at Object.urlParse [as parse] (node:url:167:13)
at [eval]:1:33
at Script.runInThisContext (node:vm:123:12)
at Object.runInThisContext (node:vm:299:38)
at node:internal/process/execution:79:19
at [eval]-wrapper:6:22
at evalScript (node:internal/process/execution:78:60)
at node:internal/main/eval_string:28:3 {
input: 'x://0.0,1.1/',
code: 'ERR_INVALID_URL'
}
$ node --version && node -e "console.log(require('node:url').parse('x://0.0,1/').host)"
v18.17.0
0.0,1
$ node --version && node -e "console.log(require('node:url').parse('x://a.a.a.a,b.b.b.b/').host)"
v18.17.0
a.a.a.a,b.b.b.b
It seems to result in an Invalid URL error under the following conditions
- v18.17.0
- When specifying a URL with a hostname that includes numbers, dots, and a comma
I use a comma in the hostname when specifying multiple hosts in MongoDB.
https://www.mongodb.com/docs/manual/reference/connection-string/#standard-connection-string-format aduh95 commented on Jul 21, 2023 richardlau commented on Jul 21, 2023 I guess this is a duplicate of #48850? Reacted by Antoine du Hamel aduh95 commented on Jul 21, 2023 arcanis commented on Jul 21, 2023 Seems it's not a problem with Yarn itself but, out of curiosity, why is your custom registry hostname containing commas? I didn't even know this was supported 😅 lemire commented on Jul 21, 2023 anonrig commented on Jul 21, 2023 The issue is with ada::idna and how it returns empty string for 0.0,1.1 input. node -e "console.log(require('url').domainToASCII('0.0,1.1'))" PikachuEXE commented on Sep 21, 2023 davidecarpini commented on Mar 28, 2024 yeah updating node from v18.17.0 -> v18.20.0 fixed the issue 🎉
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|