🌳
pt0/deployF/dockerF/regDnsRetryAI.mts
3const isEnotfound = (err: any): boolean => err?.code === 'ENOTFOUND' || err?.cause?.code === 'ENOTFOUND'
5export const withTransientDnsRetry = async <T,>(fn: () => Promise<T>, {attempts = 12, intervalMs = 8000} = {}): Promise<T> => {
6 for (let i = 0; i < attempts; i++) {
7 try {
8 return await fn()
9 } catch (err: any) {
10 if (!isEnotfound(err) || i === attempts - 1) throw err
11 console.log(`ENOTFOUND (transient, external-dns may still be propagating) — retry ${i + 1}/${attempts - 1}`)
12 await sleep(intervalMs)
13 }
14 }
15 throw new Error('unreachable')