Skip to content

Commit 1c09776

Browse files
cjihrigdanielleadams
authored andcommitted
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 ??. PR-URL: #37550 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 25a5f0b commit 1c09776

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-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

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

0 commit comments

Comments
 (0)