-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
Description
- Version: All
- Platform: All
- Subsystem: process
I have been investigating some behaviors of node-chakracore, and I found some confusing code around the process
object. In https://github.com/nodejs/node/blob/master/lib/internal/bootstrap_node.js#L17 the global process
object instance has its __proto__
replaced with a fresh object that in turn has __proto__
of EventEmitter.prototype
. That is, process.__proto__ !== process.__proto__.constructor.prototype
and process.__proto__.__proto__ === EventEmitter.prototype
.
What is the reason behind this, and why not simply set process.__proto__.constructor.prototype.__proto__
to be EventEmitter.prototype
, preferably in the native code where process
's constructor function is defined (although I haven't checked the order of instantiation of EventEmitter
and process
yet)?
The reason that I care about this is it is currently blocking an improvement in node-chakracore regarding how some objects toString()
to something like [object process]
rather than [object Object]
. That improvement works for all cases except for the global process
instance because it works by adding a Symbol.toStringTag
to the object prototype, which is explicitly overridden for process
.