Skip to content

Handle private package npm metadata fetching failures better #65

Description

@kricsleo

Clear and concise description of the problem

When fetching npm meta for private packages, it prints warnings like:

Failed to get npm meta for: [ 'undefined@undefined' ]

I know the private package's meta can't be fetched from the https://npm.antfu.dev/ endpoint, but it seems the error wasn't handled correctly.

Suggested solution

const result = await getLatestVersionBatch(queue, { metadata: true })
for (const r of result) {
if (r.publishedAt) {
onResult(r)
}
else {
missingSpecs.add(`${r.name}@${r.version}`)
}

The result might be:

{
  url: '/...',
  statusCode: 500,
  statusMessage: '',
  message: '[GET] "https://registry.npmjs.org/some-private-package": 404 Not Found'
}

We could either handle this to improve the warning logs (insteas of undefined@undefined)
or fetch npm meta using current private registry URL (e.g., https://private-registry.com/some-private-package)

Alternative

No response

Additional context

I'm willing to submit a PR for this. 🙌🏻

Validations

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

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions