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

Unhandled Exception leading to Ambiguous and Unhelpful 404 Error | Corepack #204

Open
jeremiah-snee-openx opened this issue Nov 1, 2022 · 3 comments

Comments

@jeremiah-snee-openx
Copy link

Version

v18.12.0

Platform

Darwin MBPM1-OP-43 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 arm64

Subsystem

corepack

What steps will reproduce the bug?

Open Existing node project

Add "packageManager": "[email protected]", to package.json

Run in terminal
rm -rf node_modules
corepack enable
corepack prepare pnpm@latest --activate
pnpm install or pnpm version

How often does it reproduce? Is there a required condition?

Anytime invalid package version used for PNPM

What is the expected behavior?

Handle Error with helpful response.
e.g.

Invalid Package.Json:112 config for packageManager.
Requested pnpm version 7.13.14 is invalid
"packageManager": "[email protected]",

What do you see instead?

Unhandled, Ambiguous and Unhelpful Error.

Internal Error: Server answered with HTTP 404
    at ClientRequest.<anonymous> (/Users/jeremiah.snee/.asdf/installs/nodejs/18.12.0/lib/node_modules/corepack/dist/corepack.js:16060:31)
    at Object.onceWrapper (node:events:628:26)
    at ClientRequest.emit (node:events:513:28)
    at HTTPParser.parserOnIncomingClient (node:_http_client:693:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:117:17)
    at TLSSocket.socketOnData (node:_http_client:534:22)
    at TLSSocket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10) 

Additional information

Simple Fix.

Check https://registry.npmjs.org/pnpm for valid matching version before creating http request.

@aduh95
Copy link
Contributor

aduh95 commented Nov 1, 2022

I can reproduce.

mkdir repro
cd repro
echo '{"packageManager": "[email protected]"}' > package.json
corepack pnpm version
cd ..
rm -r repro

Would you like to send a PR to fix this?

@jeremiah-snee-openx
Copy link
Author

Sure thing.

Will fork and create PR.

@DLLluoluo
Copy link

+1

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

No branches or pull requests

3 participants