I'm trying to enable DNS cache for my app but looking at the DNS requests using tcdump the DNS TTL isn't respected.
DNS TTL isn't respected
DNS TTL is respected
npm install got
const got = require('got');
setInterval(() => {
got('https://google.com',{dnsCache: true}).then(response =>{
console.log(`${response.body},`);
});
}, 1000);
you can see the DNS requests going on using tcpdump:
tcpdump -i any -A -vv port 53
we have such bug in our applications
I think one workaround would be to provide your own CacheableLookup instance.
import got from 'got';
import CacheableLookup from 'cacheable-lookup';
const dnsCache = new CacheableLookup();
setInterval(() => {
got('https://google.com', { dnsCache }).then(response =>{
console.log(`${response.body},`);
});
}, 1000);
Thank you @known-as-bmf the workaround seems to work, but i'd like to see this fixed in got as well.
Any maintainers looking at this issue? @sindresorhus @szmarczak ?
I'll look at this later today.
const instance = got.extend({dnsCache: true});
instance('https://google.com').then(response =>{
console.log(`${response.body.length}`);
});
Works. So that means got('https://google.com', {dnsCache: true}) generates a new CacheableLookup instance every time. Fixing this now.
This also causes a memory leak. Good spot!
@szmarczak thank you fixing this when can we have a release with the fix in it?
I'll do one tomorrow.
@szmarczak sorry to bug you further, is there anything that is blocking a tag release?
Sorry it took so long. Released 11.5.2.
Thank you @szmarczak !
I got your email. I'm pretty sure I made also an NPM release... Weird, I access publish anymore and when I try to log in it loads indefinitely.
@sindresorhus Can you try to publish a new NPM version (11.5.2)?
@szmarczak Done. I think it failed because npm had some downtime.
thank you @sindresorhus and @szmarczak !