From f6711b9ba3f9ea1f98cd24d4edfb73dc1ce23c93 Mon Sep 17 00:00:00 2001 From: kuriyosh Date: Mon, 20 Dec 2021 13:29:55 +0900 Subject: [PATCH] lib: fix consistency of methods that emit warnings --- lib/internal/dns/utils.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/internal/dns/utils.js b/lib/internal/dns/utils.js index 5dc5b8830c0bfd..58d3eaafcaa6c9 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;