Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

dns: do not parse JSON when response is not ok #3331

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/node/internal/internal_dns_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ export async function sendDnsRequest(
},
method: 'GET',
});
if (!response.ok) {
throw new DnsError(name, errorCodes.BADRESP, syscall);
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
json = await response.json();
} catch {
throw new DnsError(name, errorCodes.BADQUERY, syscall);
} catch (e) {
throw e instanceof DnsError
? e
: new DnsError(name, errorCodes.BADQUERY, syscall);
}

if ('error' in json) {
Expand Down
Loading