-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Bug Fix for Issue #17668 - Unused prototype objects from V8 FunctionTemplate initialization #20321
Bug Fix for Issue #17668 - Unused prototype objects from V8 FunctionTemplate initialization #20321
Conversation
You might need to change your commit messages to conform to the Commit Guidelines |
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.
Can you squash your commits and write a commit log using the format described in the contribution guide? Thanks.
.binding('udp_wrap').UDP.prototype.bind6.prototype), | ||
'undefined', | ||
'Unnecessary prototype "process.binding("udp_wrap").\ | ||
UDP.prototype.bind6.prototype" was generated!'); |
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.
-
Does this pass
make lint
? -
I'd maybe drop the message, it's just restating the code as prose.
-
Perhaps additionally check that
'prototype' in UDP.prototype.bind6
is false. -
Maybe check a few more methods, also from other binding objects (e.g.
process.binding('tcp_wrap').TCP
)
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.
@bnoordhuis I have verified that my tests pass make lint
. I also cut down the messages in my asserts to say only the names of the prototypes that they are testing, and nothing else, to avoid bloat. Furthermore, I added a few more method tests, including tests for process.binding('tcp_wrap').TCP
, and some protoype in
tests as well.
Please let me know if there are any further improvements needed.
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.
LGTM, assuming @bnoordhuis's comments get fixed.
Should we run CITGM on this? |
9aac6b7
to
f1cf34e
Compare
f1cf34e
to
b2e21f2
Compare
@TimothyGu @bnoordhuis I just added a new squashed commit with the changes that @bnoordhuis requested. Please let me know if everything checks out OK. Thank you! |
CITGM against master: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1387/ |
require('../common/fixtures'); | ||
|
||
// This test ensures that unnecessary prototypes are no longer | ||
// being genrated by Environment::NewFunctionTemplate |
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.
Nit: typo in generated
. While being on it, please also punctuate the sentence (add a dot at the end).
@@ -0,0 +1,57 @@ | |||
'use strict'; | |||
require('../common'); | |||
require('../common/fixtures'); |
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.
Nit: unnecessary require (../common/fixtures
).
|
||
const assert = require('assert'); | ||
|
||
|
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.
Nit: unnecessary double line breaks.
|
||
assert.strictEqual((process | ||
.binding('udp_wrap').UDP.prototype.bind6.prototype), undefined, | ||
'process.binding("udp_wrap").UDP.prototype.bind6.prototype'); |
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.
All the process.[...].prototype === undefined
checks in here are redundant and should be removed.
'prototype' in process.[...]
already checks this as well.
As soon as that is the case, the tests could be shortened to e.g.,
[
process.binding('udp_wrap').UDP.prototype.bind6,
process.binding('tcp_wrap').TCP.prototype.bind6,
...
].forEach((binding, i) => {
assert.strictEqual('prototype' in binding, false, `Test ${i} failed`);
});
Added an optional parameter of type v8::ConstructorBehavior to Environment::NewFunctionTemplate, defaulting to v8::ConstructorBehavior::kAllow. Also modified Environment::SetProtoMethod to pass v8::ConstructorBehavior::kThrow to its call to Environment::NewFunctionTemplate. Fixes: nodejs#17668 Refs: nodejs#20321
b2e21f2
to
18108b4
Compare
@BridgeAR I've updated my commit to reflect the changes you requested above. I've also ensured that the updated tests pass |
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.
Just reaffirming my earlier approval :)
Landed in 64348f5 🎉 Congratulations to your first commit! |
Added an optional parameter of type v8::ConstructorBehavior to Environment::NewFunctionTemplate, defaulting to v8::ConstructorBehavior::kAllow. Also modified Environment::SetProtoMethod to pass v8::ConstructorBehavior::kThrow to its call to Environment::NewFunctionTemplate. Fixes: #17668 Refs: #20321 PR-URL: #20321 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Added an optional parameter of type v8::ConstructorBehavior to Environment::NewFunctionTemplate, defaulting to v8::ConstructorBehavior::kAllow. Also modified Environment::SetProtoMethod to pass v8::ConstructorBehavior::kThrow to its call to Environment::NewFunctionTemplate. Fixes: #17668 Refs: #20321 PR-URL: #20321 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Added an optional parameter of type v8::ConstructorBehavior to Environment::NewFunctionTemplate, defaulting to v8::ConstructorBehavior::kAllow. Also modified Environment::SetProtoMethod to pass v8::ConstructorBehavior::kThrow to its call to Environment::NewFunctionTemplate. Fixes: #17668 Refs: #20321 PR-URL: #20321 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Added an optional parameter of type v8::ConstructorBehavior to Environment::NewFunctionTemplate, defaulting to v8::ConstructorBehavior::kAllow. Also modified Environment::SetProtoMethod to pass v8::ConstructorBehavior::kThrow to its call to Environment::NewFunctionTemplate. Fixes: #17668 Refs: #20321 PR-URL: #20321 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
For issue #17668. I followed the advice of @TimothyGu to implement this fix. Please let me know if there are any issues, and I will address them as soon as possible.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes9 JS tests here fail, although they fail when I make a fresh clone of the repo, so I do not believe they are failing due to my commits.