mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2025-12-24 02:39:18 -05:00
fix: remove FetchAPI-related code
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 }),
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user