diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2021-01-20 23:47:17 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-20 15:47:17 +0100 |
commit | 0a159bea15473254399e80c8e1536c0bb7f80fcf (patch) | |
tree | 1cb2266e0de3dcdb08b8ecec912a5f2d201b9f6e | |
parent | ffb4b32e9246dec2d452f81d530e8738e19e5a4e (diff) |
fix(ops/net): fix panic in op_dns_resolve (#9187)
-rw-r--r-- | cli/tests/resolve_dns.ts | 6 | ||||
-rw-r--r-- | cli/tests/resolve_dns.ts.out | 1 | ||||
-rw-r--r-- | runtime/ops/net.rs | 3 |
3 files changed, 9 insertions, 1 deletions
diff --git a/cli/tests/resolve_dns.ts b/cli/tests/resolve_dns.ts index 35abfc803..7865d9680 100644 --- a/cli/tests/resolve_dns.ts +++ b/cli/tests/resolve_dns.ts @@ -34,3 +34,9 @@ console.log(JSON.stringify(srv)); console.log("TXT"); console.log(JSON.stringify(txt)); + +try { + await Deno.resolveDns("not-found-example.com", "A", nameServer); +} catch (e) { + console.log("Error thrown for not-found-example.com"); +} diff --git a/cli/tests/resolve_dns.ts.out b/cli/tests/resolve_dns.ts.out index 10bd78e8a..78381e6c6 100644 --- a/cli/tests/resolve_dns.ts.out +++ b/cli/tests/resolve_dns.ts.out @@ -14,3 +14,4 @@ SRV [{"priority":0,"weight":100,"port":1234,"target":"srv.com."}] TXT [["foo","bar"]] +Error thrown for not-found-example.com diff --git a/runtime/ops/net.rs b/runtime/ops/net.rs index aa97be00b..e3864b38a 100644 --- a/runtime/ops/net.rs +++ b/runtime/ops/net.rs @@ -629,7 +629,8 @@ async fn op_dns_resolve( let results: Vec<DnsReturnRecord> = resolver .lookup(query, record_type, Default::default()) - .await? + .await + .map_err(|e| generic_error(format!("{}", e)))? .iter() .filter_map(rdata_to_return_record(record_type)) .collect(); |