Skip to content

Commit 9dca43e

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 ??. PR-URL: #37550 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 934d3f0 commit 9dca43e

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)