镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
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 <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 25a5f0b commit 1c09776

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎lib/domain.js‎

Lines changed: 1 addition & 1 deletion
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;
Lines changed: 17 additions & 0 deletions
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)