Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fallbackDuration behaviour doesn't match docs #35

Open
pimterry opened this issue Feb 15, 2021 · 1 comment
Open

fallbackDuration behaviour doesn't match docs #35

pimterry opened this issue Feb 15, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@pimterry
Copy link
Contributor

fallbackDuration is documented as:

When the DNS server responds with ENOTFOUND or ENODATA and the OS reports that the entry is available, it will use dns.lookup(...) directly for the requested hostnames for the specified amount of time (in seconds).

In reality, it's not a cache time, it's a periodic reset frequency:

this._hostnamesToFallback = new Set();
if (fallbackDuration < 1) {
this._fallback = false;
} else {
this._fallback = true;
const interval = setInterval(() => {
this._hostnamesToFallback.clear();
}, fallbackDuration * 1000);

For example, if it's set to 1 hour, and then 55 minutes after creating the CacheableLookup instance a hostname lookup fails, the fallback usage will only be cached for 5 minutes (the time until the next reset).

This isn't a big problem for me particularly right now, just something I noticed.

@szmarczak szmarczak added the bug Something isn't working label Feb 16, 2021
@szmarczak
Copy link
Owner

Good spot! I must've overlooked this. Will fix this ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants