Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 21362cc

Browse filesBrowse files
cjihrigaduh95
authored andcommitted
punycode: limit deprecation warning
DEP0040 is an extremely annoying warning. Most of the people seeing it cannot do anything about it. This commit updates the warning logic to only emit outside of node_modules. This is similar to other warnings such as the Buffer() constructor warning. Ideally, this should be backported to Node 22. Refs: #47202 PR-URL: #56632 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 56b2148 commit 21362cc
Copy full SHA for 21362cc

File tree

Expand file treeCollapse file tree

2 files changed

+15
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-10
lines changed
Open diff view settings
Collapse file

‎lib/punycode.js‎

Copy file name to clipboardExpand all lines: lib/punycode.js
+12-7Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
'use strict';
2-
3-
process.emitWarning(
4-
'The `punycode` module is deprecated. Please use a userland ' +
5-
'alternative instead.',
6-
'DeprecationWarning',
7-
'DEP0040',
8-
);
2+
const {
3+
isInsideNodeModules,
4+
} = internalBinding('util');
5+
6+
if (!isInsideNodeModules(100, true)) {
7+
process.emitWarning(
8+
'The `punycode` module is deprecated. Please use a userland ' +
9+
'alternative instead.',
10+
'DeprecationWarning',
11+
'DEP0040',
12+
);
13+
}
914

1015
/** Highest positive signed 32-bit float value */
1116
const maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
Collapse file
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
node:punycode:49
1+
node:punycode:54
22
throw new RangeError(errors[type]);
33
^
44

55
RangeError: Invalid input
6-
at error (node:punycode:49:8)
7-
at Object.decode (node:punycode:242:5)
6+
at error (node:punycode:54:8)
7+
at Object.decode (node:punycode:247:5)
88
at Object.<anonymous> (*core_line_numbers.js:13:10)
99

1010
Node.js *

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.