-
Notifications
You must be signed in to change notification settings - Fork 31.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
inspect: fix pop undefined when array prototype pop deleted #36742
base: main
Are you sure you want to change the base?
Conversation
There are a few perf regressions, but that might be an acceptable trade-off.
|
Can we add a test for this? I think the perf hit might be worth it for the robustness in this case, although I wonder if @nodejs/util would agree or not. |
Note that this also uses node/lib/internal/util/inspect.js Line 771 in b489173
node/lib/internal/util/inspect.js Line 991 in b489173
|
@ExE-Boss Those changes are not in the scope of the fix but I can raise another PR to move them to primordials. |
If one explicitly deletes the array prototype in the repl instance then the method to check for `pop` seen in the context starts giving error. Reason being primordials is not used and userland has modified the prototype. Fixed by using array pop method primordial.
b489173
to
23dff58
Compare
@ExE-Boss Updated PR to include other primordials as well. |
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/905/ (queued, will 404 until it starts) |
Any reason not to rebase and land this? |
I believe @Trott had requested a test for this in #36742 (comment), so that might be the only thing lacking. |
Sure will add UTs |
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.
util.inspect is quite performance sensitive. It is a sync API that many people use in their production, no matter if it's mainly meant for debugging. As such taking a performance hit does not seem right to me.
If one explicitly deletes the array prototype in the repl instance then
the method to check for
pop
seen in the context starts giving error.Reason being primordials is not used and userland has modified the
prototype.
Fixed by using array pop method primordial.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes