revert: remove retry to external API requests

This commit is contained in:
Gauthier
2024-07-11 15:35:35 +02:00
parent 6d9a1c596e
commit eddbf2d0ec
5 changed files with 0 additions and 78 deletions

View File

@@ -1,6 +1,4 @@
import { getSettings } from '@server/lib/settings';
import rateLimit from '@server/utils/rateLimit';
import retry from '@server/utils/retry';
import type NodeCache from 'node-cache';
// 5 minute default TTL (in seconds)
@@ -39,11 +37,6 @@ class ExternalAPI {
this.fetch = fetch;
}
const settings = getSettings();
if (settings.main.retryCount) {
this.fetch = retry(this.fetch, settings.main.retryCount);
}
this.baseUrl = baseUrl;
this.params = params;
this.defaultHeaders = {

View File

@@ -118,7 +118,6 @@ export interface MainSettings {
mediaServerType: number;
partialRequestsEnabled: boolean;
locale: string;
retryCount: number;
}
interface PublicSettings {
@@ -325,7 +324,6 @@ class Settings {
mediaServerType: MediaServerType.NOT_CONFIGURED,
partialRequestsEnabled: true,
locale: 'en',
retryCount: 0,
},
plex: {
name: '',

View File

@@ -1,13 +0,0 @@
import type { AllSettings } from '@server/lib/settings';
const migrateRetryCount = (settings: any): AllSettings => {
return {
...settings,
main: {
...settings.main,
retryCount: settings.main.retryCount ?? 0,
},
};
};
export default migrateRetryCount;

View File

@@ -1,23 +0,0 @@
export default function retry<
T extends (...args: Parameters<T>) => Promise<U>,
U
>(fn: T, retryCount: number): (...args: Parameters<T>) => Promise<U> {
const fnWithRetries = async (
retryCount: number,
...args: Parameters<T>
): Promise<U> => {
try {
return await fn(...args);
} catch (e) {
if (retryCount > 1) {
return fnWithRetries(retryCount - 1, ...args);
} else {
throw e;
}
}
};
return (...args: Parameters<T>): Promise<U> => {
return fnWithRetries(retryCount, ...args);
};
}