Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ Domain.prototype.bind = function(cb) {
EventEmitter.usingDomains = true;

const eventInit = EventEmitter.init;
EventEmitter.init = function() {
EventEmitter.init = function(opts) {
ObjectDefineProperty(this, 'domain', {
configurable: true,
enumerable: false,
Expand All @@ -457,7 +457,7 @@ EventEmitter.init = function() {
this.domain = exports.active;
}

return FunctionPrototypeCall(eventInit, this);
return FunctionPrototypeCall(eventInit, this, opts);
};

const eventEmit = EventEmitter.prototype.emit;
Expand Down
2 changes: 2 additions & 0 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ EventEmitter.setMaxListeners =
}
};

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

if (this._events === undefined ||
Expand Down
8 changes: 8 additions & 0 deletions test/parallel/test-domain-ee.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ d.on('error', common.mustCall((err) => {

d.add(e);
e.emit('error', new Error('foobar'));

{
// Ensure initial params pass to origin `EventEmitter.init` function
const e = new EventEmitter({ captureRejections: true });
const kCapture = Object.getOwnPropertySymbols(e)
.find((it) => it.description === 'kCapture');
assert.strictEqual(e[kCapture], true);
}