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 — 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 #48855

New issue
Copy link
New issue
Copy link
Closed
Closed
yarn 1.x.x invalid url with node 18.17.0 VS 18.16.1#48855
Copy link
Labels
urlIssues and PRs related to the legacy built-in url module.Issues and PRs related to the legacy built-in url module.

Description

@FrederickEngelhardt
FrederickEngelhardt
opened on Jul 20, 2023
Issue body actions

Version

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?

  1. Every time after installing 18.17.0 from 18.16.1. So far, this issue is specific to a monorepo being used.
  2. 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

  1. 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:

  • URL.parse fails on URLs with comma separated hosts #48850
Reacted by Gerrick Bivins, Tim Dettrick, liaoyu and Steven

Activity

Next
  1. anonrig commented on Jul 20, 2023

    @anonrig
    anonrig
    on Jul 20, 2023
    Member
    More actions

    Can you share the URL causing this error? cc @nodejs/url

  2. anonrig
    added
    whatwg-urlIssues and PRs related to the WHATWG URL implementation.Issues and PRs related to the WHATWG URL implementation.
    on Jul 20, 2023
  3. FrederickEngelhardt commented on Jul 20, 2023

    @FrederickEngelhardt
    FrederickEngelhardt
    on Jul 20, 2023
    Author
    More actions
     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".
    
  4. aduh95
    added
    urlIssues and PRs related to the legacy built-in url module.Issues and PRs related to the legacy built-in url module.
    and removed
    whatwg-urlIssues and PRs related to the WHATWG URL implementation.Issues and PRs related to the WHATWG URL implementation.
    on Jul 20, 2023
  5. aduh95 commented on Jul 20, 2023

    @aduh95
    aduh95
    on Jul 20, 2023
    Contributor
    More actions

    Looking at the stack trace, it seems to be related to the legacy Url class, not the WHATWG URL class.

    The related code on Yarn source is at https://github.com/yarnpkg/yarn/blob/158d96dce95313d9a00218302631cd263877d164/src/resolvers/exotics/git-resolver.js#L38

    /cc @arcanis

    Reacted by Frederick Engelhardt
  6. aduh95 commented on Jul 20, 2023

    @aduh95
    aduh95
    on Jul 20, 2023
    Contributor
    More actions

    The throw is located at

    node/lib/url.js

    Lines 444 to 446 in a39b8a2

    if (this.hostname === '' || forbiddenHostChars.test(this.hostname)) {
    throw new ERR_INVALID_URL(url);
    }

    The hostname is set at

    node/lib/url.js

    Line 433 in a39b8a2

    this.hostname = toASCII(this.hostname, true);

    And toASCII is imported from internal/idna:

    node/lib/url.js

    Line 34 in a39b8a2

    const { toASCII } = require('internal/idna');

    Which itself reexports it from internal/url:

    node/lib/internal/idna.js

    Lines 3 to 4 in a39b8a2

    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

  7. anonrig
    added
    v18.x
    on Jul 21, 2023
  8. akkunchoi commented on Jul 21, 2023

    @akkunchoi
    akkunchoi
    on Jul 21, 2023
    More actions
    $ 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

  9. aduh95 commented on Jul 21, 2023

    @aduh95
    aduh95
    on Jul 21, 2023
    Contributor
    More actions

    Starting bisecting

  10. richardlau commented on Jul 21, 2023

    @richardlau
    richardlau
    on Jul 21, 2023
    Member
    More actions

    I guess this is a duplicate of #48850?

    Reacted by Antoine du Hamel
  11. aduh95 commented on Jul 21, 2023

    @aduh95
    aduh95
    on Jul 21, 2023
    Contributor
    More actions

    0dc485e is the first bad commit /cc @anonrig

  12. arcanis commented on Jul 21, 2023

    @arcanis
    arcanis
    on Jul 21, 2023
    Contributor
    More actions

    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 😅

  13. lemire commented on Jul 21, 2023

    @lemire
    lemire
    on Jul 21, 2023
    Member
    More actions

    The ada URL parsing library itself has no beef with commas, as you can see in the playground...

    https://www.ada-url.com/playground?url=x%3A%2F%2F0.0%2C1%2F

  14. anonrig commented on Jul 21, 2023

    @anonrig
    anonrig
    on Jul 21, 2023
    Member
    More actions

    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'))"

  15. 16 remaining items

  16. Ceres6
    added 4 commits that reference this issue on Aug 14, 2023

    test: validate host with commas on url.parse

    ba96a46

    lib: remove invalid parameter to toASCII

    c433de3

    test: validate host with commas on url.parse

    6c0c565

    lib: remove invalid parameter to toASCII

    bb7ffa8
  17. UlisesGascon
    added 2 commits that reference this issue on Aug 14, 2023

    test: validate host with commas on url.parse

    17a1be6

    lib: remove invalid parameter to toASCII

    5affce3
  18. RafaelGSS
    added 2 commits that reference this issue on Aug 15, 2023

    test: validate host with commas on url.parse

    3680a66

    lib: remove invalid parameter to toASCII

    420b85c
  19. ruyadorno
    added 2 commits that reference this issue on Aug 16, 2023

    test: validate host with commas on url.parse

    2de9868

    lib: remove invalid parameter to toASCII

    69aaf8b
  20. PikachuEXE commented on Sep 21, 2023

    @PikachuEXE
    PikachuEXE
    on Sep 21, 2023
    More actions

    Seems fixed in https://github.com/nodejs/node/releases/tag/v18.18.0

  21. anonrig
    closed this as completedon Sep 21, 2023
  22. davidecarpini commented on Mar 28, 2024

    @davidecarpini
    davidecarpini
    on Mar 28, 2024
    More actions

    yeah updating node from v18.17.0 -> v18.20.0 fixed the issue 🎉

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

    urlIssues and PRs related to the legacy built-in url module.Issues and PRs related to the legacy built-in url module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — 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.