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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user