-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
util: harden util.inspect #21869
util: harden util.inspect #21869
Conversation
This makes sure values without prototype will still be inspected properly and do not cause errors. It restores the original information if possible. Besides that it fixes an issue with boxed symbols: extra keys were not visualized so far.
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.
might wanna use uncurryThis instead of .call
PTAL. It would be nice to get another LG. @devsnek are you also fine with landing it as is? |
lib/util.js
Outdated
if (ctx.showHidden) { | ||
formatter = formatWeakSet; | ||
} else { | ||
extra = '<items unknown>'; | ||
} | ||
} else if (isWeakMap(value)) { | ||
braces[0] = `${getPrefix(constructor, tag)}{`; | ||
braces[0] = `${getPrefix(constructor, tag) || 'WeakMap '}{`; |
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.
Would it make more sense to make the || 'thing '
be a param of getPrefix
to add the trailing space then?
I addressed both comments. |
Landed in 10c850b 🎉 |
This makes sure values without prototype will still be inspected properly and do not cause errors. It restores the original information if possible. Besides that it fixes an issue with boxed symbols: extra keys were not visualized so far. PR-URL: nodejs#21869 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
#20961 landed and I was able to cherry-pick this with just a trivial conflict to fix. |
This makes sure values without prototype will still be inspected properly and do not cause errors. It restores the original information if possible. Besides that it fixes an issue with boxed symbols: extra keys were not visualized so far. PR-URL: #21869 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
@targos seems like this did not yet land in any release. I would like to pull this out until #22437 landed. In that case both could land together. Otherwise the latter would be semver-major as I remove support for the Symbol.manipulation again. It is just difficult to deal with that properly all at once. |
@targos yes, awesome. Thanks a lot. |
This makes sure values without prototype will still be inspected properly and do not cause errors. It restores the original information if possible. Besides that it fixes an issue with boxed symbols: extra keys were not visualized so far. PR-URL: #21869 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
This makes sure values without prototype will still be inspected
properly and do not cause errors. It restores the original
information if possible.
Besides that it fixes an issue with boxed symbols: extra keys were
not visualized so far.
The main focus here is correctness and performance. I am not always happy with the code but it is not always easy to "fix" these things. I could not find a fix for e.g. regular expressions and if someone has an idea, please let me know!
Fixes #19511
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes