Skip to content

Commit 74bd312

Browse files
MoonBallBethGriggs
authored andcommitted
domain: pass opts to EventEmitter.init
PR-URL: #41414 Fixes: #41391 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent e8062bf commit 74bd312

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

lib/domain.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ Domain.prototype.bind = function(cb) {
446446
EventEmitter.usingDomains = true;
447447

448448
const eventInit = EventEmitter.init;
449-
EventEmitter.init = function() {
449+
EventEmitter.init = function(opts) {
450450
ObjectDefineProperty(this, 'domain', {
451451
configurable: true,
452452
enumerable: false,
@@ -457,7 +457,7 @@ EventEmitter.init = function() {
457457
this.domain = exports.active;
458458
}
459459

460-
return FunctionPrototypeCall(eventInit, this);
460+
return FunctionPrototypeCall(eventInit, this, opts);
461461
};
462462

463463
const eventEmit = EventEmitter.prototype.emit;

lib/events.js

+2
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ EventEmitter.setMaxListeners =
321321
}
322322
};
323323

324+
// If you're updating this function definition, please also update any
325+
// re-definitions, such as the one in the Domain module (lib/domain.js).
324326
EventEmitter.init = function(opts) {
325327

326328
if (this._events === undefined ||

test/parallel/test-domain-ee.js

+8
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,11 @@ d.on('error', common.mustCall((err) => {
1818

1919
d.add(e);
2020
e.emit('error', new Error('foobar'));
21+
22+
{
23+
// Ensure initial params pass to origin `EventEmitter.init` function
24+
const e = new EventEmitter({ captureRejections: true });
25+
const kCapture = Object.getOwnPropertySymbols(e)
26+
.find((it) => it.description === 'kCapture');
27+
assert.strictEqual(e[kCapture], true);
28+
}

0 commit comments

Comments
 (0)