Skip to content

[Bug?]: Error for packages without any versions #6630

Closed as not planned
Closed as not planned
@cd-work

Description

@cd-work

Self-service

  • I'd be willing to implement a fix

Describe the bug

When running Yarn against a package that provides an empty versions object on the metadata, the following error is printed:

➤ YN0027: typescript@unknown can't be resolved to a satisfying range
➤ YN0001: TypeError: Cannot read properties of undefined (reading 'dist')
    at Fv.getCandidates (/home/chris/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:688:7154)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Pg.getCandidates (/home/chris/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:141:1271)
    at async uH (/home/chris/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:401:9441)
    at async /home/chris/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:401:8776
    at async C (/home/chris/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:401:7127)
    at async T2 (/home/chris/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:401:8456)
    at async /home/chris/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:402:531
    at async Promise.all (index 0)
    at async /home/chris/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:402:488
➤ Errors happened when preparing the environment required to run this command.

This was reproduced with a custom registry, however other package managers like npm and pnpm do not run into errors with this. It seems reasonable to me that an empty versions object should be treated like a 404 on the endpoint, which gives essentially the same output just without the "ugly" backtrace and error.

The endpoint hit here specifically should be https://registry.npmjs.org/typescript, or its corresponding version with the private registry.

To reproduce

It might be possible to reproduce this with a package that had versions completely unpublished, I'm not entirely sure to which degree that is possible with NPM.

The easiest way is likely to run it against a proxy where one has full control over the response. I'd imagine it should be easy to reproduce by just editing the response object in the code itself, even if that is not a "real world" reproduction of this bug.

If more detailed reproduction steps are necessary, please let me know. But I'd imagine this should be quite simple to fix if it is considered to be a bug with Yarn.

Environment

System:
    OS: Linux 6.11 Arch Linux
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
  Binaries:
    Node: 22.10.0 - /tmp/xfs-81f281ff/node
    Yarn: 1.22.19 - /tmp/xfs-81f281ff/yarn
    npm: 10.9.0 - /usr/bin/npm
    pnpm: 9.12.2 - /usr/bin/pnpm

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleIssues that didn't get attentionwaiting for feedbackWill autoclose in a while unless more data are provided

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions