diff --git a/lib/internal/bootstrap_node.js b/lib/internal/bootstrap_node.js index 2ad6ad63bb490b..0827326fad7782 100644 --- a/lib/internal/bootstrap_node.js +++ b/lib/internal/bootstrap_node.js @@ -13,10 +13,9 @@ const EventEmitter = NativeModule.require('events'); process._eventsCount = 0; + const origProcProto = Object.getPrototypeOf(process); Object.setPrototypeOf(process, Object.create(EventEmitter.prototype, { - constructor: { - value: process.constructor - } + constructor: Object.getOwnPropertyDescriptor(origProcProto, 'constructor') })); EventEmitter.call(process); diff --git a/test/parallel/test-process-prototype.js b/test/parallel/test-process-prototype.js new file mode 100644 index 00000000000000..0a0de8123d127d --- /dev/null +++ b/test/parallel/test-process-prototype.js @@ -0,0 +1,15 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const EventEmitter = require('events'); + +const proto = Object.getPrototypeOf(process); + +assert(proto instanceof EventEmitter); + +const desc = Object.getOwnPropertyDescriptor(proto, 'constructor'); + +assert.strictEqual(desc.value, process.constructor); +assert.strictEqual(desc.writable, true); +assert.strictEqual(desc.enumerable, false); +assert.strictEqual(desc.configurable, true);