Skip to content

Commit cde272a

Browse files
MSLaguanaaddaleax
authored andcommitted
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: nodejs#14699 PR-URL: nodejs#14715 Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 062beb0 commit cde272a

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

lib/internal/bootstrap_node.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
process._eventsCount = 0;
1515

1616
const origProcProto = Object.getPrototypeOf(process);
17-
Object.setPrototypeOf(process, Object.create(EventEmitter.prototype, {
18-
constructor: Object.getOwnPropertyDescriptor(origProcProto, 'constructor')
19-
}));
17+
Object.setPrototypeOf(origProcProto, EventEmitter.prototype);
2018

2119
EventEmitter.call(process);
2220

test/parallel/test-process-prototype.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const EventEmitter = require('events');
55

66
const proto = Object.getPrototypeOf(process);
77

8+
assert(process instanceof process.constructor);
89
assert(proto instanceof EventEmitter);
910

1011
const desc = Object.getOwnPropertyDescriptor(proto, 'constructor');

0 commit comments

Comments
 (0)