diff --git a/server/utils/dnsCacheManager.ts b/server/utils/dnsCacheManager.ts index 8154a3f37..f186e925a 100644 --- a/server/utils/dnsCacheManager.ts +++ b/server/utils/dnsCacheManager.ts @@ -936,44 +936,3 @@ class DnsCacheManager { } export const dnsCache = new DnsCacheManager(); - -// For better error handling in fetch operations -if (typeof global.fetch === 'function') { - const originalFetch = global.fetch; - - global.fetch = async function ( - ...args: Parameters - ): Promise { - try { - const response = await originalFetch(...args); - return response; - } catch (error) { - try { - let hostname = ''; - const firstArg = args[0]; - - if (typeof firstArg === 'string') { - hostname = new URL(firstArg).hostname; - } else if (firstArg instanceof URL) { - hostname = firstArg.hostname; - } else if (firstArg instanceof Request) { - hostname = new URL(firstArg.url).hostname; - } - - if (hostname && error.message?.includes('fetch failed')) { - dnsCache.reportNetworkError(hostname); - logger.warn( - `Reporting network error for ${hostname}: ${error.message}`, - { - label: 'FetchInterceptor', - } - ); - } - } catch (urlError) { - // - } - - throw error; - } - } as typeof global.fetch; -} diff --git a/src/components/Settings/SettingsJobsCache/index.tsx b/src/components/Settings/SettingsJobsCache/index.tsx index 99831cb5b..5a6ebefea 100644 --- a/src/components/Settings/SettingsJobsCache/index.tsx +++ b/src/components/Settings/SettingsJobsCache/index.tsx @@ -264,10 +264,7 @@ const SettingsJobs = () => { }; const flushDnsCache = async (hostname: string) => { - const res = await fetch(`/api/v1/settings/cache/dns/${hostname}/flush`, { - method: 'POST', - }); - if (!res.ok) throw new Error(); + await axios.post(`/api/v1/settings/cache/dns/${hostname}/flush`); addToast( intl.formatMessage(messages.dnscacheflushed, { hostname: hostname }), {