szmarczak / cacheable-lookup

A cacheable dns.lookup(…) that respects TTL :tada:
MIT License
193 stars 29 forks source link

cacheable-lookup does not appear to refresh cached host-file resolutions when the hosts file is altered #24

Closed fluffynuts closed 4 years ago

fluffynuts commented 4 years ago

Tested on windows 10, node 12.16.2, via got

  1. clone the repo at https://github.com/fluffynuts/cacheable-lookup-issue-demo
  2. add this line to your hosts file: 127.0.0.1 server.dev.local
  3. npm ci
  4. npm start
  5. in another term, run test.bat

If you get ENOTFOUND for the second test and you're on windows, it may be because your hosts file has CRLF EOL. Change with dos2unix (get from scoop) and try again, until all calls pass

Now, with the api still running, update the hosts file -- delete the line from [2] or alter it, eg 196.25.1.1 server.dev.local.

Expected behavior: if deleting the line, I should get ENOENT, if altering to 196.25.1.1, then I expect an ECONNREFUSED (196.25.1.1 is a dns server for South Africa, iirc)

Actual behavior: even if I wait and retry in 30 seconds, the calls never fail until I restart the api. Then they consistently fail, even if I undo the changes to the system hosts file and wait.

szmarczak commented 4 years ago

You're using an outdated version of cacheable-lookup: 4.1.2. The newest is 4.2.3.

szmarczak commented 4 years ago

Yep, the issue exists on 4.1.2. Please update.

fluffynuts commented 4 years ago

I'll raise an issue at got's repo. I'm not choosing this version - it's what's coming down with got.

szmarczak commented 4 years ago

Can you try cacheable-lookup@5.0.0 out? Thanks.