-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Gracefully handle "Cannot read property .match of undefined" #1009
Gracefully handle "Cannot read property .match of undefined" #1009
Conversation
4c2a0e8
to
3d02e27
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome! 🎉 thanks @danielleadams
Sorry for the delay @danielleadams I was meant to write back to you after the last release - I tried landing this in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are currently failing
btw, if you rebase on top of current |
oh whoops! Ok.. let me rebase and see if it fixes, or otherwise fix it. |
b29be19
to
74305db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome 🎉 thanks again @danielleadams 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
digging a bit more into the output from each of the CI targets, there's actually a bunch of silent failures in the form of:
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\npm\cache\_logs\2020-06-11T20_02_29_720Z-debug.log
which seems to imply the broken chain of promise is still an issue 😞
…ted due to dependency shrinkwrap object being empty
…hen a dependency has an empty object value; make lint fixes
be3c45b
to
5455e0b
Compare
@ruyadorno I made changes to how errors are handling... instead of importing and using the error handler, I returned a failed promise with an error from the if statement. The tests pass, which tells me that the error is passed up the call stack and still handled. Let me know what you think 👍 |
What / Why
There's a bug in which an npm command will raise an error
Cannot read property .match on undefined
and exit the script with an error. There are a few open issues:npm install
)npm install
#961 (occurs withnpm install
)npm audit fix
)npm uninstall --save-dev
)I've run into this with
npm prune
, but I was unable to reproduce it while looking into it. This doesn't fix the root of the issue, which it appears that empty parameters are being generated in the lock file something like this:And causing an undefined error here: https://github.com/npm/cli/blob/latest/lib/install/inflate-shrinkwrap.js#L87
Because there is no
"version"
key that is passed in here: https://github.com/npm/cli/blob/latest/lib/install/inflate-shrinkwrap.js#L99 (which is returning anundefined
).Solution
This catches a dependency if it's empty and displays an error message to the user to regenerate the package-lock.json or npm-shrinkwrap.json.
TODO
write testsReferences