Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dns.lookup options..family throw errors when using 'IPv4' #54961

Closed
tomek3e opened this issue Sep 16, 2024 · 4 comments
Closed

dns.lookup options..family throw errors when using 'IPv4' #54961

tomek3e opened this issue Sep 16, 2024 · 4 comments
Labels
dns Issues and PRs related to the dns subsystem. doc Issues and PRs related to the documentations.

Comments

@tomek3e
Copy link

tomek3e commented Sep 16, 2024

Version

v22.4.0

Platform

Microsoft Windows NT 10.0.19045.0 x64

Subsystem

dns

What steps will reproduce the bug?

import dns from 'node:dns/promises';

async function dnsLookup(){
await dns.lookup("localhost", {family: 'IPv4' })
}

dnsLookup()

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

Function not to throw.

What do you see instead?

Throws
TypeError: The property 'options.family' must be one of: 0, 4, 6. Received 'IPv4'

Additional information

Same happens on v20.14.0, v18.18.0.
According to the documentation IPv4 and IPv6 should be accepted https://nodejs.org/docs/latest-v22.x/api/dns.html#dnslookuphostname-options-callback

family | The record family. Must be 4, 6, or 0. For backward compatibility reasons,'IPv4' and 'IPv6' are interpreted as 4 and 6 respectively. The value 0 indicates that either an IPv4 or IPv6 address is returned. If the value 0 is used with { all: true } (see below), either one of or both IPv4 and IPv6 addresses are returned, depending on the system's DNS resolver. Default: 0.

@climba03003
Copy link
Contributor

climba03003 commented Sep 16, 2024

It is expected to removed since the start of node@18.
So, the problems is related to document is not up-to-date.

Reference #41431

@avivkeller avivkeller added doc Issues and PRs related to the documentations. dns Issues and PRs related to the dns subsystem. labels Sep 16, 2024
lpinca added a commit to lpinca/node that referenced this issue Sep 16, 2024
The `'IPv4'` and `'IPv6'` values are no longer supported.

Fixes: nodejs#54961
lpinca added a commit to lpinca/node that referenced this issue Sep 16, 2024
The `'IPv4'` and `'IPv6'` values are no longer supported.

Fixes: nodejs#54961
@lpinca
Copy link
Member

lpinca commented Sep 16, 2024

The documentation is ok. The value 'IPv4' and 'IPv6' are supported in the callback variant of dns.lookup().

@tomek3e
Copy link
Author

tomek3e commented Sep 16, 2024

@lpinca Indeed, upon checking https://nodejs.org/api/dns.html#dnspromiseslookuphostname-options it is indeed unsupported.
It is however incorrectly documented in @types/node/dns/promises.d.ts which uses LookupOptions interface from the callback version.

declare module "dns/promises" {
import {
...,
LookupOptions,
....
} from "node:dns";

@avivkeller avivkeller closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2024
@lpinca
Copy link
Member

lpinca commented Sep 16, 2024

@tomek3e that should be fixed in the DefinitelyTyped repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dns Issues and PRs related to the dns subsystem. doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants