Skip to content

Commit

Permalink
punycode: limit deprecation warning
Browse files Browse the repository at this point in the history
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: nodejs#47202
  • Loading branch information
cjihrig committed Jan 16, 2025
1 parent 0e7ec5e commit 0040582
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/punycode.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
'use strict';

process.emitWarning(
'The `punycode` module is deprecated. Please use a userland ' +
'alternative instead.',
'DeprecationWarning',
'DEP0040',
);
const {
isInsideNodeModules,
} = internalBinding('util');

if (!isInsideNodeModules(100, true)) {
process.emitWarning(
'The `punycode` module is deprecated. Please use a userland ' +
'alternative instead.',
'DeprecationWarning',
'DEP0040',
);
}

/** Highest positive signed 32-bit float value */
const maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
Expand Down

0 comments on commit 0040582

Please sign in to comment.