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

Node v20 support #7

Open
Codelica opened this issue Jan 17, 2024 · 2 comments · May be fixed by #8
Open

Node v20 support #7

Codelica opened this issue Jan 17, 2024 · 2 comments · May be fixed by #8

Comments

@Codelica
Copy link

Sadly this module no longer works in Node v20+. Going to take a look but seems core dns lookup must have been reworked.

@Codelica
Copy link
Author

Codelica commented Jan 19, 2024

So basically dns.lookup() has always had an option named all which if set to true would have the lookup return an array of address+family objects. From the docs:

With the all option set to true, the arguments for callback change to (err, addresses), with addresses being an array of objects with the properties address and family.

Evil-dns just returns a single object regardless, so this would have been an existing bug for anything calling with options.all=true.

However in Node 20 this got more visible, as the core net code now includes options.all=true by default which makes it into all sort of things. (Like Got via core http client which then uses net, etc). So it becomes an issue with most calls.

In the end the answer is to check for that option and return as an array if needed.

Going from:

return process.nextTick(() => callback(null, entry.ip, entry.family));

To:

if (typeof(options) === 'object' && options.all) {
  return process.nextTick(() => callback(null, [{address: entry.ip, family: entry.family}]));
}
else return process.nextTick(() => callback(null, entry.ip, entry.family));

@jpage-godaddy jpage-godaddy linked a pull request Mar 28, 2024 that will close this issue
@Codelica
Copy link
Author

Thanks for the PR @jpage-godaddy and sorry for the late reply, I'm currently away checking out colleges w/ my daughter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant