fix: remove FetchAPI-related code

This commit is contained in:
Gauthier
2025-05-07 16:51:09 +02:00
committed by gauthier-th
parent 7b2b45b066
commit 03d905ae98
2 changed files with 1 additions and 45 deletions

View File

@@ -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<typeof originalFetch>
): Promise<Response> {
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;
}

View File

@@ -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 }),
{