fix(ext/node): Fix dns.lookup when promisified with options.all (#29167)

Fixes https://github.com/denoland/deno/issues/29074

Co-authored-by: Satya Rohith <me@satyarohith.com>
This commit is contained in:
Divy Srivastava 2025-05-05 20:46:00 -07:00 committed by GitHub
parent d8857b9aee
commit 2edc70e679
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View file

@ -133,7 +133,11 @@ function onlookupall(
};
}
this.callback(null, parsedAddresses, undefined, netPermToken);
if (this.callback.length > 1) {
this.callback(null, parsedAddresses, undefined, netPermToken);
} else {
this.callback(null, parsedAddresses);
}
}
type LookupCallback = (

View file

@ -5,6 +5,7 @@ import { assert, assertEquals } from "@std/assert";
import * as path from "@std/path";
import * as http from "node:http";
import * as dns from "node:dns";
import util from "node:util";
import console from "node:console";
Deno.test("[node/net] close event emits after error event - when host is not found", async () => {
@ -274,3 +275,11 @@ Deno.test("dns.resolve with ttl", async () => {
assert(ret2.length > 0);
assert(typeof ret2[0] === "string");
});
Deno.test("[node/dns] dns.lookup (all=true) util promisify", async () => {
const lookup = util.promisify(dns.lookup);
const result = await lookup("localhost", { all: true });
assert(Array.isArray(result));
assert(typeof result[0].address === "string");
assert(typeof result[0].family === "number");
});