From eddbf2d0ec61b9832fa6ff230d62d85a6231901c Mon Sep 17 00:00:00 2001 From: Gauthier Date: Thu, 11 Jul 2024 15:35:35 +0200 Subject: [PATCH] revert: remove retry to external API requests --- server/api/externalapi.ts | 7 ---- server/lib/settings/index.ts | 2 -- .../migrations/0002_add_retry_count.ts | 13 -------- server/utils/retry.ts | 23 ------------- .../Settings/SettingsMain/index.tsx | 33 ------------------- 5 files changed, 78 deletions(-) delete mode 100644 server/lib/settings/migrations/0002_add_retry_count.ts delete mode 100644 server/utils/retry.ts diff --git a/server/api/externalapi.ts b/server/api/externalapi.ts index bf9038925..136e9c21e 100644 --- a/server/api/externalapi.ts +++ b/server/api/externalapi.ts @@ -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 = { diff --git a/server/lib/settings/index.ts b/server/lib/settings/index.ts index e3bbf1351..7c117c110 100644 --- a/server/lib/settings/index.ts +++ b/server/lib/settings/index.ts @@ -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: '', diff --git a/server/lib/settings/migrations/0002_add_retry_count.ts b/server/lib/settings/migrations/0002_add_retry_count.ts deleted file mode 100644 index b73860f55..000000000 --- a/server/lib/settings/migrations/0002_add_retry_count.ts +++ /dev/null @@ -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; diff --git a/server/utils/retry.ts b/server/utils/retry.ts deleted file mode 100644 index 08696e776..000000000 --- a/server/utils/retry.ts +++ /dev/null @@ -1,23 +0,0 @@ -export default function retry< - T extends (...args: Parameters) => Promise, - U ->(fn: T, retryCount: number): (...args: Parameters) => Promise { - const fnWithRetries = async ( - retryCount: number, - ...args: Parameters - ): Promise => { - try { - return await fn(...args); - } catch (e) { - if (retryCount > 1) { - return fnWithRetries(retryCount - 1, ...args); - } else { - throw e; - } - } - }; - - return (...args: Parameters): Promise => { - return fnWithRetries(retryCount, ...args); - }; -} diff --git a/src/components/Settings/SettingsMain/index.tsx b/src/components/Settings/SettingsMain/index.tsx index 127b97b2d..f7aac0d96 100644 --- a/src/components/Settings/SettingsMain/index.tsx +++ b/src/components/Settings/SettingsMain/index.tsx @@ -47,11 +47,6 @@ const messages = defineMessages('components.Settings.SettingsMain', { cacheImages: 'Enable Image Caching', cacheImagesTip: 'Cache externally sourced images (requires a significant amount of disk space)', - retryCount: 'Retry Count', - retryCountTip: - 'Number of retry when a network request to an external service fails', - retryCountHoverTip: - 'Do NOT enable this setting unless you understand what you are doing!', trustProxy: 'Enable Proxy Support', trustProxyTip: 'Allow Jellyseerr to correctly register client IP addresses behind a proxy', @@ -142,7 +137,6 @@ const SettingsMain = () => { partialRequestsEnabled: data?.partialRequestsEnabled, trustProxy: data?.trustProxy, cacheImages: data?.cacheImages, - retryCount: data?.retryCount, }} enableReinitialize validationSchema={MainSettingsSchema} @@ -164,7 +158,6 @@ const SettingsMain = () => { partialRequestsEnabled: values.partialRequestsEnabled, trustProxy: values.trustProxy, cacheImages: values.cacheImages, - retryCount: values.retryCount, }), }); if (!res.ok) throw new Error(); @@ -346,32 +339,6 @@ const SettingsMain = () => { /> -
- -
-
- -
- {errors.retryCount && - touched.retryCount && - typeof errors.retryCount === 'string' && ( -
{errors.retryCount}
- )} -
-