diff --git a/ext/node/polyfills/dns.ts b/ext/node/polyfills/dns.ts index 306ccb4fcf..91fe8b79d2 100644 --- a/ext/node/polyfills/dns.ts +++ b/ext/node/polyfills/dns.ts @@ -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 = ( diff --git a/tests/unit_node/net_test.ts b/tests/unit_node/net_test.ts index e48dec7a1d..2faad11dc5 100644 --- a/tests/unit_node/net_test.ts +++ b/tests/unit_node/net_test.ts @@ -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"); +});