-
Notifications
You must be signed in to change notification settings - Fork 30k
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
process: keep process prototype in inheritance chain #14715
Conversation
lib/internal/bootstrap_node.js
Outdated
Object.setPrototypeOf(process, Object.create(EventEmitter.prototype, { | ||
constructor: Object.getOwnPropertyDescriptor(origProcProto, 'constructor') | ||
})); | ||
Object.setPrototypeOf(Object.getPrototypeOf(process), EventEmitter.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.
Hi, @MSLaguana!
Sorry for the nits, but we have two ESLint complaints here.
16:11 error 'origProcProto' is assigned a value but never used no-unused-vars
17:1 error Line 17 exceeds the maximum line length of 80 max-len
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.
Gah, that's what I get for writing the same thing on a few machines to test it all out. Fixed.
e43c580
to
c3dc069
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.
Seems like it should be possible to add a test for this. Maybe just assert.strictEqual(process.__proto__, process.__proto__.constructor.prototype);
inside test/parallel/test-process-prototype.js
?
Hi, @MSLaguana! Thanks for the PR and trying to introduce some more predictability/intuitiveness to Node.js. |
The global `process` object had its prototype replaced with a fresh object that had `EventEmitter.prototype` as its prototype. With this change, the original `process.constructor.prototype` is modified to have `EventEmitter.prototype` as its prototype, reflecting that `process` objects are also `EventEmitter`s. Fixes: nodejs#14699
c3dc069
to
a0b4a4a
Compare
@Trott fair point, added a test to make sure that |
Fresh CI: https://ci.nodejs.org/job/node-test-commit/11761/ This should be ready. |
CI is good Landed in cde272a, thanks for the PR! 🎉 |
The global `process` object had its prototype replaced with a fresh object that had `EventEmitter.prototype` as its prototype. With this change, the original `process.constructor.prototype` is modified to have `EventEmitter.prototype` as its prototype, reflecting that `process` objects are also `EventEmitter`s. Fixes: #14699 PR-URL: #14715 Reviewed-By: Anna Henningsen <[email protected]>
The global `process` object had its prototype replaced with a fresh object that had `EventEmitter.prototype` as its prototype. With this change, the original `process.constructor.prototype` is modified to have `EventEmitter.prototype` as its prototype, reflecting that `process` objects are also `EventEmitter`s. Fixes: #14699 PR-URL: #14715 Reviewed-By: Anna Henningsen <[email protected]>
Should this be backported to |
ping re: backport |
Sorry for the delay. I don't think it is important to backport this, it was more for cleaning up (and to allow improvements in node-chakracore). |
The global
process
object had its prototype replaced with afresh object that had
EventEmitter.prototype
as its prototype.With this change, the original
process.constructor.prototype
ismodified to have
EventEmitter.prototype
as its prototype, reflectingthat
process
objects are alsoEventEmitter
s.Fixes: #14699
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
process