mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
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:
parent
d8857b9aee
commit
2edc70e679
2 changed files with 14 additions and 1 deletions
|
@ -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 = (
|
||||
|
|
|
@ -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");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue