summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorLeo Kettmeir <crowlkats@toaxl.com>2023-02-11 15:14:02 +0100
committerGitHub <noreply@github.com>2023-02-11 14:14:02 +0000
commita55f0eb2fc005016dc9d44bfe4771dd451df9c30 (patch)
tree7d2a2ea9f6271a18e6d4f12309e3fa244e979bfa /cli
parente22ebc6b6bb733a111ba02781e53e186f9c8bcc8 (diff)
feat: add signal option to Deno.resolveDns (#17384)
Closes #14406
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/testdata/run/resolve_dns.ts22
-rw-r--r--cli/tests/testdata/run/resolve_dns.ts.out2
-rw-r--r--cli/tsc/dts/lib.deno.ns.d.ts6
3 files changed, 30 insertions, 0 deletions
diff --git a/cli/tests/testdata/run/resolve_dns.ts b/cli/tests/testdata/run/resolve_dns.ts
index ae6ed70a4..a2d0fd046 100644
--- a/cli/tests/testdata/run/resolve_dns.ts
+++ b/cli/tests/testdata/run/resolve_dns.ts
@@ -69,3 +69,25 @@ try {
} catch (e) {
console.log(e.message);
}
+
+try {
+ const ac = new AbortController();
+ queueMicrotask(() => ac.abort());
+ await Deno.resolveDns("www.example.com", "A", {
+ ...nameServer,
+ signal: ac.signal,
+ });
+} catch (e) {
+ console.log(e.name);
+}
+
+try {
+ const ac = new AbortController();
+ ac.abort();
+ await Deno.resolveDns("www.example.com", "A", {
+ ...nameServer,
+ signal: ac.signal,
+ });
+} catch (e) {
+ console.log(e.name);
+}
diff --git a/cli/tests/testdata/run/resolve_dns.ts.out b/cli/tests/testdata/run/resolve_dns.ts.out
index f41dc68bc..025028395 100644
--- a/cli/tests/testdata/run/resolve_dns.ts.out
+++ b/cli/tests/testdata/run/resolve_dns.ts.out
@@ -24,3 +24,5 @@ TXT
[["I","am","a","txt","record"],["I","am","another","txt","record"],["I am a different","txt record"],["key=val"]]
Error NotFound thrown for not-found-example.com
Provided record type is not supported
+AbortError
+AbortError
diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts
index 58dd602d8..33a568b65 100644
--- a/cli/tsc/dts/lib.deno.ns.d.ts
+++ b/cli/tsc/dts/lib.deno.ns.d.ts
@@ -4989,6 +4989,12 @@ declare namespace Deno {
* @default {53} */
port?: number;
};
+ /**
+ * An abort signal to allow cancellation of the DNS resolution operation.
+ * If the signal becomes aborted the resolveDns operation will be stopped
+ * and the promise returned will be rejected with an AbortError.
+ */
+ signal?: AbortSignal;
}
/** If {@linkcode Deno.resolveDns} is called with `"CAA"` record type