Skip to content

Commit

Permalink
domain: add name to monkey-patched emit function
Browse files Browse the repository at this point in the history
The domain module monkey patches EventEmitter.prototype.emit(),
however the function's name was becoming the empty string. This
commit forces the new emit function to have the proper name.
  • Loading branch information
cjihrig committed Feb 28, 2021
1 parent b54c8c5 commit 10200f3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ EventEmitter.init = function() {
};

const eventEmit = EventEmitter.prototype.emit;
EventEmitter.prototype.emit = function(...args) {
EventEmitter.prototype.emit = function emit(...args) {
const domain = this.domain;

const type = args[0];
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-domain-dep0097.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const domain = require('domain');

process.on('warning', common.mustCall((warning) => {
assert.strictEqual(warning.code, 'DEP0097');
assert.match(warning.message, /Triggered by calling <anonymous> on process/);
assert.match(warning.message, /Triggered by calling emit on process/);
}));

domain.create().run(() => {
Expand Down

0 comments on commit 10200f3

Please sign in to comment.