Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using custom npm repository #1468

Open
cmaga opened this issue Oct 24, 2024 · 1 comment
Open

Error when using custom npm repository #1468

cmaga opened this issue Oct 24, 2024 · 1 comment

Comments

@cmaga
Copy link

cmaga commented Oct 24, 2024


Steps to Reproduce

This issue is difficult to reproduce since it's happening when using internal packages that are published to an internal npm repository. So I'm coming up with my own way to reproduce the error based on what I think is going wrong. Might not be the best way.

NCU fails to fetch the information for the package and throws an unhandled error. The current workaround for me is to just skip checking for that package but this should be handled in a cleaner way. Seems to have something to do with the name.

Steps:

  • Add a package that contains no npm repo such as: "@me/fake-package-from-me": "1.0" to your package.json
  • run: ncu

Current Behavior

Throws the following error and does no updates

[===-----------------] 4/29 13%Mk: 400 Bad Request - GET http://240.10.0.1:36339/ws/16nowkfxgqqsb476bdqdl1io8pmpr7c0/uyuzgck3/npm/%40me%2Ffake-package-from-me - Bad request. The package name '@me' is invalid.
    at /local/home/vmagachr/.local/share/mise/installs/node/18.18.2/lib/node_modules/npm-check-updates/build/index.js:347:974
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  headers: [Object: null prototype] {
    'content-type': [ 'application/json' ],
    'x-wire-requestid': [ '3eb15841-5e18-475e-a3ec-31e2b22e0ba4' ],
    'content-length': [ '75' ],
    connection: [ 'keep-alive' ],
    'x-fetch-attempts': [ '1' ]
  },
  statusCode: 400,
  code: 'E400',
  method: 'GET',
  uri: 'http://240.10.0.1:36339/ws/16nowkfxgqqsb476bdqdl1io8pmpr7c0/uyuzgck3/npm/%40me%2Ffake-package-from-me',
  body: {
    success: false,
    error: "Bad request. The package name '@me' is invalid."
  },
  pkgid: '@me/fake-package-from-me'
}
Unhandled Rejection! This is a bug and should be reported: https://github.com/raineorshine/npm-check-updates/issues

Expected Behavior

Not being able to find information about a specific package should not cause the rest of the checks to not run/fail. For example, npm outdated and npm-check(from the npm-check package gracefully handle this scenario and simply ignores packages it cannot find information for. Removing the "@me" from the fake package seems to make this error go away.

@raineorshine
Copy link
Owner

raineorshine commented Oct 24, 2024

Hi, thanks for reporting.

npm-check-updates is designed to ignore a 404 error code, which is the standard error when a package is not found. It seems that your custom registry is returning a 400 Bad Request due to the org prefix.

I'm not able to reproduce this exactly, since I don't have a registry that returns 400, but I tried to extend the error catching logic anyway. Try v17.1.3 and let me know if that works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants