Permalink
Browse files

process: keep process prototype in inheritance chain

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 <anna@addaleax.net>
  • Loading branch information...
MSLaguana authored and addaleax committed Aug 9, 2017
1 parent 062beb0 commit cde272a066923a1b93a10a8121b0ce572308d13c
Showing with 2 additions and 3 deletions.
  1. +1 −3 lib/internal/bootstrap_node.js
  2. +1 −0 test/parallel/test-process-prototype.js
@@ -14,9 +14,7 @@
process._eventsCount = 0;
const origProcProto = Object.getPrototypeOf(process);
Object.setPrototypeOf(process, Object.create(EventEmitter.prototype, {
constructor: Object.getOwnPropertyDescriptor(origProcProto, 'constructor')
}));
Object.setPrototypeOf(origProcProto, EventEmitter.prototype);
EventEmitter.call(process);
@@ -5,6 +5,7 @@ const EventEmitter = require('events');
const proto = Object.getPrototypeOf(process);
assert(process instanceof process.constructor);
assert(proto instanceof EventEmitter);
const desc = Object.getOwnPropertyDescriptor(proto, 'constructor');

0 comments on commit cde272a

Please sign in to comment.