diff --git a/lib/domain.js b/lib/domain.js index 4a018c52f845f0..acd5dc8221df31 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -130,7 +130,7 @@ function emitMakeCallbackDeprecation({ target, method }) { 'Using a domain property in MakeCallback is deprecated. Use the ' + 'async_context variant of MakeCallback or the AsyncResource class ' + 'instead. ' + - `(Triggered by calling ${method?.name ?? ''} ` + + `(Triggered by calling ${method?.name || ''} ` + `on ${target?.constructor?.name}.)`, 'DeprecationWarning', 'DEP0097'); sendMakeCallbackDeprecation = true; @@ -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]; diff --git a/test/parallel/test-domain-dep0097.js b/test/parallel/test-domain-dep0097.js new file mode 100644 index 00000000000000..05b5c74b30d98e --- /dev/null +++ b/test/parallel/test-domain-dep0097.js @@ -0,0 +1,17 @@ +'use strict'; +const common = require('../common'); + +common.skipIfInspectorDisabled(); + +const assert = require('assert'); +const domain = require('domain'); +const inspector = require('inspector'); + +process.on('warning', common.mustCall((warning) => { + assert.strictEqual(warning.code, 'DEP0097'); + assert.match(warning.message, /Triggered by calling emit on process/); +})); + +domain.create().run(() => { + inspector.open(); +});