Got doesn't resolve short dns names and fails with error.
...
Got resolve short dns names.
...
await got(`http://short-name-host`)
With v11 it produce
(node:53) UnhandledPromiseRejectionWarning: RequestError: ENOTFOUND short-name-host
at ClientRequest.<anonymous> (/opt/service/node_modules/got/dist/source/core/index.js:759:25)
at Object.onceWrapper (events.js:422:26)
at ClientRequest.emit (events.js:327:22)
at ClientRequest.origin.emit (/opt/service/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20)
at Socket.socketErrorListener (_http_client.js:461:9)
at Socket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:96:8)
at emitErrorCloseNT (internal/streams/destroy.js:68:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
at CacheableLookup.lookupAsync (/opt/service/node_modules/cacheable-lookup/source/index.js:167:19)
It's easily reproduced also with some kubernetes dns names as well. E.g. http://short-name-host.default and so on.
And it starts working only if you provide full name like short-name-host.default.svc.cluster.local.
In other words v11 doesn't work well with anything that's written in search section of resolv.conf
Might be an issue with https://github.com/szmarczak/cacheable-lookup#readme, so @szmarczak maybe you can figure out.
I don't have kubernetes so I cannot reproduce...
But I think I can reproduce in another way, will check tomorrow.
I can confirm that this issue on Kubernetes.
Short host name resolving works as expected. It's just that it doesn't communicate with resolv.conf.
Okay, will it be fixed? Right now I have worked around by disabling DNS cache.
Actually on Kubernetes, the CoreDNS service has its own caching mechanism so we are not seeing much difference between cache enable and disable.
I can reproduce on Windows
The only possible way is to fallback to dns.lookup(...), which for sure will have a negative impact on performance.
@szmarczak I think some flag or option that will switch "preformance mode" and regular dns lookup should be good enough. Or try to fallback to dns.lookup in case of ENOTFOUND error.
The code is pretty much finished, I just need to write the tests.
https://github.com/szmarczak/cacheable-lookup/pull/15
The only possible way is to fallback to dns.lookup(...), which for sure will have a negative impact on performance.
Well, by default it remembers the errors for 150ms and the OS results for 1s, so there should be no impact at all.
Fixed in https://github.com/szmarczak/cacheable-lookup/commit/dfefae26f67b5d78be6aaace795b3cb8fccf27d4 but haven't made a release yet. I'll try to fix #1173 first.
Fixed in [email protected]
Most helpful comment
I can confirm that this issue on Kubernetes.