serverless-dns: DNS packet encode / decode unhandled exceptions
After adding a caching layer, reliance on dns-packet encoding / decoding has gone up. In our tests, these unhandled exceptions have cropped up in the meanwhile:
"exceptions": [
{
"name": "TypeError",
"message": "Failed to execute function: parameter 1 is not of type 'Response'.",
}
],
"logs": [
{
"message": [
"Error At : DNSParserWrap -> Encode"
],
"level": "error",
},
{
"message": [
"TypeError: e.copy is not a function\n at Object.encode (worker.js:10:13483)\n at Object.encode (worker.js:10:33416)\n at ce (worker.js:10:35934)\n at ne (worker.js:10:35051)\n at de.Encode (worker.js:10:36285)\n at Ue.dnsBlockResponse (worker.js:10:44687)\n at vt.Rt (worker.js:10:82128)\n at vt.executePlugin (worker.js:10:80457)\n at async worker.js:10:82801"
],
"level": "error",
}
],
"outcome": "exception",
"scriptName": null,
"exceptions": [
{
"name": "TypeError",
"message": "Failed to execute function: parameter 1 is not of type 'Response'.",
}
],
"logs": [
{
"message": [
"Error At : DNSParserWrap -> Encode"
],
"level": "error",
},
{
"message": [
"TypeError: e.copy is not a function\n at Object.encode (worker.js:10:13483)\n at Object.encode (worker.js:10:33416)\n at ce (worker.js:10:35934)\n at ne (worker.js:10:35051)\n at de.Encode (worker.js:10:36285)\n at Ue.dnsBlockResponse (worker.js:10:44687)\n at vt.Rt (worker.js:10:82128)\n at vt.executePlugin (worker.js:10:80457)\n at async worker.js:10:82801"
],
"level": "error",
}
],
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (16 by maintainers)
Commits related to this issue
- refactor(dns-resolver): Check upstream res. length (prev. commit + this) for serverless-dns/serverless-dns#25 — committed to serverless-dns/dns-blocker by amithm7 3 years ago
- fix(dns-resolver): Check upstream server 5xx error serverless-dns/serverless-dns#25 — committed to serverless-dns/dns-blocker by amithm7 3 years ago
- fix: GET & POST methods only; cors headers for browsers #25 — committed to serverless-dns/serverless-dns by amithm7 3 years ago
some more from development instance. This happens routinely.
Yes, locally upstream
POST. Safer sincePOSTcan handle arbitrary sized requests.I guess, we are long done with this one with all the recent changes and refactors.
Okay, making changes…
Could set
405res code fromcommand-control.Currently there are no checks for request method I believe. What is not a GET is assumed to be POST.
CORS headers also set “Allow request methods” to all (
*), it should be modified to be just POST & GET (and OPTIONS?)One of the decoding errors was caused by this array buffer of upstream response:
This is not a dns-packet. It is text that says: “
no downstream server available”.Searching the web shows this: https://github.com/PowerDNS/pdns/blob/f9f6a6257e43133d98a7295994d0a7c50b80e261/pdns/dnsdistdist/doh.cc#L400 Maybe what upstream (quad9 (10)) could be using.
Checking response code from upstream before decoding will probably reduce many of these errors.
Edit: It is 502 Response Code when this happens.