diff options
author | Yoshiki Kurihara <yosyos0306@gmail.com> | 2022-01-22 08:53:53 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-21 23:53:53 +0000 |
commit | feafea11545fea2672c0831d63e5526d6342e492 (patch) | |
tree | fecb70f5229741bb20ddc004c962c0bbdb44c722 | |
parent | 806c7c13f3e0a516a9b361033e5c6d4814a9cba2 (diff) | |
download | node-new-feafea11545fea2672c0831d63e5526d6342e492.tar.gz |
lib: fix consistency of methods that emit warnings
PR-URL: https://github.com/nodejs/node/pull/41249
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
-rw-r--r-- | lib/internal/dns/utils.js | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/internal/dns/utils.js b/lib/internal/dns/utils.js index 5dc5b8830c..58d3eaafca 100644 --- a/lib/internal/dns/utils.js +++ b/lib/internal/dns/utils.js @@ -178,18 +178,16 @@ function validateHints(hints) { } let invalidHostnameWarningEmitted = false; - function emitInvalidHostnameWarning(hostname) { - if (invalidHostnameWarningEmitted) { - return; + if (!invalidHostnameWarningEmitted) { + process.emitWarning( + `The provided hostname "${hostname}" is not a valid ` + + 'hostname, and is supported in the dns module solely for compatibility.', + 'DeprecationWarning', + 'DEP0118' + ); + invalidHostnameWarningEmitted = true; } - invalidHostnameWarningEmitted = true; - process.emitWarning( - `The provided hostname "${hostname}" is not a valid ` + - 'hostname, and is supported in the dns module solely for compatibility.', - 'DeprecationWarning', - 'DEP0118' - ); } let typeCoercionWarningEmitted = false; |