| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 431c04d commit a5f9ca1
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2524,17 +2524,18 @@ object can lead to crashing the application. | |||
| 2524 | 2524 | ||
| 2525 | 2525 | <!-- YAML | |
| 2526 | 2526 | changes: | |
| 2527 | + - version: REPLACEME | ||
| 2528 | + pr-url: https://github.com/nodejs/node/pull/58619 | ||
| 2529 | + description: End-of-Life. | ||
| 2527 | 2530 | - version: v11.0.0 | |
| 2528 | 2531 | pr-url: https://github.com/nodejs/node/pull/23173 | |
| 2529 | 2532 | description: Runtime deprecation. | |
| 2530 | 2533 | --> | |
| 2531 | 2534 | ||
| 2532 | - Type: Runtime | ||
| 2535 | + Type: End-of-Life | ||
| 2533 | 2536 | ||
| 2534 | 2537 | Previous versions of Node.js supported `dns.lookup()` with a falsy host name | |
| 2535 | - like `dns.lookup(false)` due to backward compatibility. | ||
| 2536 | - This behavior is undocumented and is thought to be unused in real world apps. | ||
| 2537 | - It will become an error in future versions of Node.js. | ||
| 2538 | + like `dns.lookup(false)` due to backward compatibility. This has been removed. | ||
| 2538 | 2539 | ||
| 2539 | 2540 | ### DEP0119: `process.binding('uv').errname()` private API | |
| 2540 | 2541 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,7 +42,6 @@ const { | |||
| 42 | 42 | bindDefaultResolver, | |
| 43 | 43 | setDefaultResolver, | |
| 44 | 44 | validateHints, | |
| 45 | - emitInvalidHostnameWarning, | ||
| 46 | 45 | getDefaultResultOrder, | |
| 47 | 46 | setDefaultResultOrder, | |
| 48 | 47 | errorCodes: dnsErrorCodes, | |
@@ -199,13 +198,8 @@ function lookup(hostname, options, callback) { | |||
| 199 | 198 | } | |
| 200 | 199 | ||
| 201 | 200 | if (!hostname) { | |
| 202 | - emitInvalidHostnameWarning(hostname); | ||
| 203 | - if (all) { | ||
| 204 | - process.nextTick(callback, null, []); | ||
| 205 | - } else { | ||
| 206 | - process.nextTick(callback, null, null, family === 6 ? 6 : 4); | ||
| 207 | - } | ||
| 208 | - return {}; | ||
| 201 | + throw new ERR_INVALID_ARG_VALUE('hostname', hostname, | ||
| 202 | + 'must be a non-empty string'); | ||
| 209 | 203 | } | |
| 210 | 204 | ||
| 211 | 205 | const matchedFamily = isIP(hostname); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,6 @@ const { | |||
| 11 | 11 | bindDefaultResolver, | |
| 12 | 12 | createResolverClass, | |
| 13 | 13 | validateHints, | |
| 14 | - emitInvalidHostnameWarning, | ||
| 15 | 14 | errorCodes: dnsErrorCodes, | |
| 16 | 15 | getDefaultResultOrder, | |
| 17 | 16 | setDefaultResultOrder, | |
@@ -135,8 +134,8 @@ function onlookupall(err, addresses) { | |||
| 135 | 134 | function createLookupPromise(family, hostname, all, hints, dnsOrder) { | |
| 136 | 135 | return new Promise((resolve, reject) => { | |
| 137 | 136 | if (!hostname) { | |
| 138 | - emitInvalidHostnameWarning(hostname); | ||
| 139 | - resolve(all ? [] : { address: null, family: family === 6 ? 6 : 4 }); | ||
| 137 | + reject(new ERR_INVALID_ARG_VALUE('hostname', hostname, | ||
| 138 | + 'must be a non-empty string')); | ||
| 140 | 139 | return; | |
| 141 | 140 | } | |
| 142 | 141 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -269,19 +269,6 @@ function validateHints(hints) { | |||
| 269 | 269 | } | |
| 270 | 270 | } | |
| 271 | 271 | ||
| 272 | - let invalidHostnameWarningEmitted = false; | ||
| 273 | - function emitInvalidHostnameWarning(hostname) { | ||
| 274 | - if (!invalidHostnameWarningEmitted) { | ||
| 275 | - process.emitWarning( | ||
| 276 | - `The provided hostname "${hostname}" is not a valid ` + | ||
| 277 | - 'hostname, and is supported in the dns module solely for compatibility.', | ||
| 278 | - 'DeprecationWarning', | ||
| 279 | - 'DEP0118', | ||
| 280 | - ); | ||
| 281 | - invalidHostnameWarningEmitted = true; | ||
| 282 | - } | ||
| 283 | - } | ||
| 284 | - | ||
| 285 | 272 | function setDefaultResultOrder(value) { | |
| 286 | 273 | validateOneOf(value, 'dnsOrder', validDnsOrders); | |
| 287 | 274 | dnsOrder = value; | |
@@ -352,7 +339,6 @@ module.exports = { | |||
| 352 | 339 | validateHints, | |
| 353 | 340 | validateTimeout, | |
| 354 | 341 | validateTries, | |
| 355 | - emitInvalidHostnameWarning, | ||
| 356 | 342 | getDefaultResultOrder, | |
| 357 | 343 | setDefaultResultOrder, | |
| 358 | 344 | errorCodes, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -629,21 +629,6 @@ TEST(function test_lookup_ip_promise(done) { | |||
| 629 | 629 | }); | |
| 630 | 630 | ||
| 631 | 631 | ||
| 632 | - TEST(async function test_lookup_null_all(done) { | ||
| 633 | - assert.deepStrictEqual(await dnsPromises.lookup(null, { all: true }), []); | ||
| 634 | - | ||
| 635 | - const req = dns.lookup(null, { all: true }, (err, ips) => { | ||
| 636 | - assert.ifError(err); | ||
| 637 | - assert.ok(Array.isArray(ips)); | ||
| 638 | - assert.strictEqual(ips.length, 0); | ||
| 639 | - | ||
| 640 | - done(); | ||
| 641 | - }); | ||
| 642 | - | ||
| 643 | - checkWrap(req); | ||
| 644 | - }); | ||
| 645 | - | ||
| 646 | - | ||
| 647 | 632 | TEST(async function test_lookup_all_mixed(done) { | |
| 648 | 633 | function validateResult(result) { | |
| 649 | 634 | assert.ok(Array.isArray(result)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,9 +29,9 @@ const dnsPromises = dns.promises; | |||
| 29 | 29 | (async function() { | |
| 30 | 30 | let res; | |
| 31 | 31 | ||
| 32 | - res = await dnsPromises.lookup(null); | ||
| 33 | - assert.strictEqual(res.address, null); | ||
| 34 | - assert.strictEqual(res.family, 4); | ||
| 32 | + await assert.rejects(dnsPromises.lookup(null), { | ||
| 33 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 34 | + }); | ||
| 35 | 35 | ||
| 36 | 36 | res = await dnsPromises.lookup('127.0.0.1'); | |
| 37 | 37 | assert.strictEqual(res.address, '127.0.0.1'); | |
@@ -43,10 +43,9 @@ const dnsPromises = dns.promises; | |||
| 43 | 43 | })().then(common.mustCall()); | |
| 44 | 44 | ||
| 45 | 45 | // Try resolution without hostname. | |
| 46 | - dns.lookup(null, common.mustSucceed((result, addressType) => { | ||
| 47 | - assert.strictEqual(result, null); | ||
| 48 | - assert.strictEqual(addressType, 4); | ||
| 49 | - })); | ||
| 46 | + assert.throws(() => dns.lookup(null, common.mustNotCall()), { | ||
| 47 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 48 | + }); | ||
| 50 | 49 | ||
| 51 | 50 | dns.lookup('127.0.0.1', common.mustSucceed((result, addressType) => { | |
| 52 | 51 | assert.strictEqual(result, '127.0.0.1'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,11 +29,6 @@ common.expectWarning({ | |||
| 29 | 29 | 'internal/test/binding': [ | |
| 30 | 30 | 'These APIs are for internal testing only. Do not use them.', | |
| 31 | 31 | ], | |
| 32 | - // For calling `dns.lookup` with falsy `hostname`. | ||
| 33 | - 'DeprecationWarning': { | ||
| 34 | - DEP0118: 'The provided hostname "false" is not a valid ' + | ||
| 35 | - 'hostname, and is supported in the dns module solely for compatibility.' | ||
| 36 | - } | ||
| 37 | 32 | }); | |
| 38 | 33 | ||
| 39 | 34 | assert.throws(() => { | |
@@ -145,12 +140,13 @@ assert.throws(() => dnsPromises.lookup(false, () => {}), | |||
| 145 | 140 | (async function() { | |
| 146 | 141 | let res; | |
| 147 | 142 | ||
| 148 | - res = await dnsPromises.lookup(false, { | ||
| 143 | + await assert.rejects(dnsPromises.lookup(false, { | ||
| 149 | 144 | hints: 0, | |
| 150 | 145 | family: 0, | |
| 151 | 146 | all: true | |
| 147 | + }), { | ||
| 148 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 152 | 149 | }); | |
| 153 | - assert.deepStrictEqual(res, []); | ||
| 154 | 150 | ||
| 155 | 151 | res = await dnsPromises.lookup('127.0.0.1', { | |
| 156 | 152 | hints: 0, | |
@@ -167,14 +163,13 @@ assert.throws(() => dnsPromises.lookup(false, () => {}), | |||
| 167 | 163 | assert.deepStrictEqual(res, { address: '127.0.0.1', family: 4 }); | |
| 168 | 164 | })().then(common.mustCall()); | |
| 169 | 165 | ||
| 170 | - dns.lookup(false, { | ||
| 166 | + assert.throws(() => dns.lookup(false, { | ||
| 171 | 167 | hints: 0, | |
| 172 | 168 | family: 0, | |
| 173 | 169 | all: true | |
| 174 | - }, common.mustSucceed((result, addressType) => { | ||
| 175 | - assert.deepStrictEqual(result, []); | ||
| 176 | - assert.strictEqual(addressType, undefined); | ||
| 177 | - })); | ||
| 170 | + }, common.mustNotCall()), { | ||
| 171 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 172 | + }); | ||
| 178 | 173 | ||
| 179 | 174 | dns.lookup('127.0.0.1', { | |
| 180 | 175 | hints: 0, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -193,16 +193,13 @@ assert.deepStrictEqual(dns.getServers(), []); | |||
| 193 | 193 | ||
| 194 | 194 | // dns.lookup should accept falsey values | |
| 195 | 195 | { | |
| 196 | - const checkCallback = (err, address, family) => { | ||
| 197 | - assert.ifError(err); | ||
| 198 | - assert.strictEqual(address, null); | ||
| 199 | - assert.strictEqual(family, 4); | ||
| 200 | - }; | ||
| 201 | - | ||
| 202 | 196 | ['', null, undefined, 0, NaN].forEach(async (value) => { | |
| 203 | - const res = await dnsPromises.lookup(value); | ||
| 204 | - assert.deepStrictEqual(res, { address: null, family: 4 }); | ||
| 205 | - dns.lookup(value, common.mustCall(checkCallback)); | ||
| 197 | + await assert.rejects(dnsPromises.lookup(value), { | ||
| 198 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 199 | + }); | ||
| 200 | + assert.throws(() => dns.lookup(value, common.mustNotCall()), { | ||
| 201 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 202 | + }); | ||
| 206 | 203 | }); | |
| 207 | 204 | } | |
| 208 | 205 | ||
@@ -247,52 +244,104 @@ assert.throws(() => dns.lookup('', { | |||
| 247 | 244 | name: 'TypeError' | |
| 248 | 245 | }); | |
| 249 | 246 | ||
| 250 | - dns.lookup('', { family: 4, hints: 0 }, common.mustCall()); | ||
| 247 | + assert.throws(() => { | ||
| 248 | + dns.lookup('', { family: 4, hints: 0 }, common.mustNotCall()); | ||
| 249 | + }, { | ||
| 250 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 251 | + }); | ||
| 251 | 252 | ||
| 252 | - dns.lookup('', { | ||
| 253 | - family: 6, | ||
| 254 | - hints: dns.ADDRCONFIG | ||
| 255 | - }, common.mustCall()); | ||
| 253 | + assert.throws(() => { | ||
| 254 | + dns.lookup('', { | ||
| 255 | + family: 6, | ||
| 256 | + hints: dns.ADDRCONFIG | ||
| 257 | + }, common.mustNotCall()); | ||
| 258 | + }, { | ||
| 259 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 260 | + }); | ||
| 256 | 261 | ||
| 257 | - dns.lookup('', { hints: dns.V4MAPPED }, common.mustCall()); | ||
| 262 | + assert.throws(() => { | ||
| 263 | + dns.lookup('', { hints: dns.V4MAPPED }, common.mustNotCall()); | ||
| 264 | + }, { | ||
| 265 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 266 | + }); | ||
| 258 | 267 | ||
| 259 | - dns.lookup('', { | ||
| 260 | - hints: dns.ADDRCONFIG | dns.V4MAPPED | ||
| 261 | - }, common.mustCall()); | ||
| 268 | + assert.throws(() => { | ||
| 269 | + dns.lookup('', { | ||
| 270 | + hints: dns.ADDRCONFIG | dns.V4MAPPED | ||
| 271 | + }, common.mustNotCall()); | ||
| 272 | + }, { | ||
| 273 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 274 | + }); | ||
| 262 | 275 | ||
| 263 | - dns.lookup('', { | ||
| 264 | - hints: dns.ALL | ||
| 265 | - }, common.mustCall()); | ||
| 276 | + assert.throws(() => { | ||
| 277 | + dns.lookup('', { | ||
| 278 | + hints: dns.ALL | ||
| 279 | + }, common.mustNotCall()); | ||
| 280 | + }, { | ||
| 281 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 282 | + }); | ||
| 266 | 283 | ||
| 267 | - dns.lookup('', { | ||
| 268 | - hints: dns.V4MAPPED | dns.ALL | ||
| 269 | - }, common.mustCall()); | ||
| 284 | + assert.throws(() => { | ||
| 285 | + dns.lookup('', { | ||
| 286 | + hints: dns.V4MAPPED | dns.ALL | ||
| 287 | + }, common.mustNotCall()); | ||
| 288 | + }, { | ||
| 289 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 290 | + }); | ||
| 270 | 291 | ||
| 271 | - dns.lookup('', { | ||
| 272 | - hints: dns.ADDRCONFIG | dns.V4MAPPED | dns.ALL | ||
| 273 | - }, common.mustCall()); | ||
| 292 | + assert.throws(() => { | ||
| 293 | + dns.lookup('', { | ||
| 294 | + hints: dns.ADDRCONFIG | dns.V4MAPPED | dns.ALL | ||
| 295 | + }, common.mustNotCall()); | ||
| 296 | + }, { | ||
| 297 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 298 | + }); | ||
| 274 | 299 | ||
| 275 | - dns.lookup('', { | ||
| 276 | - hints: dns.ADDRCONFIG | dns.V4MAPPED | dns.ALL, | ||
| 277 | - family: 'IPv4' | ||
| 278 | - }, common.mustCall()); | ||
| 300 | + assert.throws(() => { | ||
| 301 | + dns.lookup('', { | ||
| 302 | + hints: dns.ADDRCONFIG | dns.V4MAPPED | dns.ALL, | ||
| 303 | + family: 'IPv4' | ||
| 304 | + }, common.mustNotCall()); | ||
| 305 | + }, { | ||
| 306 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 307 | + }); | ||
| 279 | 308 | ||
| 280 | - dns.lookup('', { | ||
| 281 | - hints: dns.ADDRCONFIG | dns.V4MAPPED | dns.ALL, | ||
| 282 | - family: 'IPv6' | ||
| 283 | - }, common.mustCall()); | ||
| 309 | + assert.throws(() => { | ||
| 310 | + dns.lookup('', { | ||
| 311 | + hints: dns.ADDRCONFIG | dns.V4MAPPED | dns.ALL, | ||
| 312 | + family: 'IPv6' | ||
| 313 | + }, common.mustNotCall()); | ||
| 314 | + }, { | ||
| 315 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 316 | + }); | ||
| 284 | 317 | ||
| 285 | 318 | (async function() { | |
| 286 | - await dnsPromises.lookup('', { family: 4, hints: 0 }); | ||
| 287 | - await dnsPromises.lookup('', { family: 6, hints: dns.ADDRCONFIG }); | ||
| 288 | - await dnsPromises.lookup('', { hints: dns.V4MAPPED }); | ||
| 289 | - await dnsPromises.lookup('', { hints: dns.ADDRCONFIG | dns.V4MAPPED }); | ||
| 290 | - await dnsPromises.lookup('', { hints: dns.ALL }); | ||
| 291 | - await dnsPromises.lookup('', { hints: dns.V4MAPPED | dns.ALL }); | ||
| 292 | - await dnsPromises.lookup('', { | ||
| 319 | + await assert.rejects(dnsPromises.lookup('', { family: 4, hints: 0 }), { | ||
| 320 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 321 | + }); | ||
| 322 | + await assert.rejects(dnsPromises.lookup('', { family: 6, hints: dns.ADDRCONFIG }), { | ||
| 323 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 324 | + }); | ||
| 325 | + await assert.rejects(dnsPromises.lookup('', { hints: dns.V4MAPPED }), { | ||
| 326 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 327 | + }); | ||
| 328 | + await assert.rejects(dnsPromises.lookup('', { hints: dns.ADDRCONFIG | dns.V4MAPPED }), { | ||
| 329 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 330 | + }); | ||
| 331 | + await assert.rejects(dnsPromises.lookup('', { hints: dns.ALL }), { | ||
| 332 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 333 | + }); | ||
| 334 | + await assert.rejects(dnsPromises.lookup('', { hints: dns.V4MAPPED | dns.ALL }), { | ||
| 335 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 336 | + }); | ||
| 337 | + await assert.rejects(dnsPromises.lookup('', { | ||
| 293 | 338 | hints: dns.ADDRCONFIG | dns.V4MAPPED | dns.ALL | |
| 339 | + }), { | ||
| 340 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 341 | + }); | ||
| 342 | + await assert.rejects(dnsPromises.lookup('', { order: 'verbatim' }), { | ||
| 343 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 294 | 344 | }); | |
| 295 | - await dnsPromises.lookup('', { order: 'verbatim' }); | ||
| 296 | 345 | })().then(common.mustCall()); | |
| 297 | 346 | ||
| 298 | 347 | { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments