-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Description
I assumed this was a bug, but on looking into it, it seems deliberate:
Line 132 in 6f21671
| 'hostname must be a string or falsey'); |
@cjihrig you added this, I think, in 5086d6e (missing PR metadata), but it looks like you were cleaning up something from an earlier commit. Any ideas why falsey is allowed?
Its even tested:
node/test/parallel/test-dns-lookup.js
Lines 38 to 48 in 6f21671
| assert.doesNotThrow(() => { | |
| dns.lookup(false, { | |
| hints: 0, | |
| family: 0, | |
| all: true | |
| }, common.mustCall((error, result, addressType) => { | |
| assert.ifError(error); | |
| assert.deepStrictEqual(result, []); | |
| assert.strictEqual(addressType, undefined); | |
| })); | |
| }); |
My guess was that the intention is that if hostname is falsy, there may be enough information in options to return a useful value, in which case options should be mandatory if hostname is missing.
Except... I don't see how that can be, it looks to me you will always get no results no matter what flags you put into options, and the tests even assert that, so... why is a falsey hostname allowed?
- Version: *
- Platform: *
- Subsystem: dns
% ./node
> dns.lookup(false, console.log)
{}
> null null 4