fetch
fetch copied to clipboard
Allow passing configurable minimumCacheTime through to dns-cached-resolve
https://github.com/zeit/dns-cached-resolve/ defaults to 300s, which could be problematic with records with lower ttls. For example, AWS ELBs always use 60s.
This would require a change to https://github.com/zeit/fetch-cached-dns/ as well, I believe.
An alternative way to cope with it could be to invalidate the cached IP in case it doesn't work anymore. It's quite a lost battle but https://00f.net/2019/11/03/stop-using-low-dns-ttls/
Since we are again facing the same issue that a change in multiple repos is needed, I'm again proposing monorepoizing @zeit/fetch
.
Is it possible to invalidate it from this lib as-is, or are you offering that as an alternate approach to take going forward? It sounds fine to me--would solve for our use case.
I've read that article too, but AWS ¯\(ツ)/¯
It's theoretically possible. IIRC, you can register an error handler with @zeit/fetch
and then you might be able to dig your way into the dns resolver and ask it to refresh in the error handler: https://github.com/zeit/dns-cached-resolve/blob/master/src/dns-resolve.ts#L14
So what I mean is that an alternative could be to implement an automatic DNS refresh in case of a network error.
However, I think it would be a good idea to implement your original proposal as well.
Thank you for the report. We are archiving this project; you can read more details here: https://github.com/vercel/fetch/issues/83