diff --git a/lib/dns.js b/lib/dns.js index ac3f6d6f0ec725..f68409f2ee6743 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -50,8 +50,7 @@ const { const dnsException = errors.dnsException; -let promisesWarn = true; -let promises; // Lazy loaded +let promises = null; // Lazy loaded function onlookup(err, addresses) { if (err) { @@ -269,7 +268,7 @@ function defaultResolverSetServers(servers) { setDefaultResolver(resolver); bindDefaultResolver(module.exports, Resolver.prototype); - if (promises !== undefined) + if (promises !== null) bindDefaultResolver(promises, promises.Resolver.prototype); } @@ -318,10 +317,9 @@ Object.defineProperties(module.exports, { configurable: true, enumerable: false, get() { - if (promisesWarn) { + if (promises === null) { promises = require('internal/dns/promises'); promises.setServers = defaultResolverSetServers; - promisesWarn = false; process.emitWarning('The dns.promises API is experimental', 'ExperimentalWarning'); } diff --git a/lib/fs.js b/lib/fs.js index 2e4bdc89647aac..1a720f618189fd 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -86,12 +86,11 @@ const { validateUint32 } = require('internal/validators'); -let promisesWarn = true; let truncateWarn = true; let fs; // Lazy loaded -let promises; +let promises = null; let watchers; let ReadFileContext; let ReadStream; @@ -1931,9 +1930,8 @@ Object.defineProperties(fs, { configurable: true, enumerable: false, get() { - if (promisesWarn) { + if (promises === null) { promises = require('internal/fs/promises'); - promisesWarn = false; process.emitWarning('The fs.promises API is experimental', 'ExperimentalWarning'); }