Skip to content

Commit b54c8c5

Browse files
committed
domain: show falsy names as anonymous for DEP0097
Many anonymous functions use the empty string as their name. Since the DEP0097 logic was using nullish coalescing, these functions were not being displayed as anonymous. This commit updates the logic to use || instead of ??.
1 parent 1e34df1 commit b54c8c5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/domain.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function emitMakeCallbackDeprecation({ target, method }) {
130130
'Using a domain property in MakeCallback is deprecated. Use the ' +
131131
'async_context variant of MakeCallback or the AsyncResource class ' +
132132
'instead. ' +
133-
`(Triggered by calling ${method?.name ?? '<anonymous>'} ` +
133+
`(Triggered by calling ${method?.name || '<anonymous>'} ` +
134134
`on ${target?.constructor?.name}.)`,
135135
'DeprecationWarning', 'DEP0097');
136136
sendMakeCallbackDeprecation = true;

test/parallel/test-domain-dep0097.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const domain = require('domain');
5+
6+
process.on('warning', common.mustCall((warning) => {
7+
assert.strictEqual(warning.code, 'DEP0097');
8+
assert.match(warning.message, /Triggered by calling <anonymous> on process/);
9+
}));
10+
11+
domain.create().run(() => {
12+
process.kill(process.pid, 'SIGUSR1');
13+
});

0 commit comments

Comments
 (0)