From 797045335bedccb55c797a162087d7302b5f9289 Mon Sep 17 00:00:00 2001 From: Kyle Pollich Date: Thu, 7 Dec 2023 12:03:53 -0500 Subject: [PATCH] Add max request timeout --- x-pack/plugins/fleet/server/services/agents/versions.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/fleet/server/services/agents/versions.ts b/x-pack/plugins/fleet/server/services/agents/versions.ts index 7583b91ac62791..b5a09bc99e2cbc 100644 --- a/x-pack/plugins/fleet/server/services/agents/versions.ts +++ b/x-pack/plugins/fleet/server/services/agents/versions.ts @@ -24,6 +24,7 @@ const AGENT_VERSION_BUILD_FILE = 'x-pack/plugins/fleet/target/agent_versions_lis // Endpoint maintained by the web-team and hosted on the elastic website const PRODUCT_VERSIONS_URL = 'https://www.elastic.co/api/product_versions'; +const MAX_REQUEST_TIMEOUT = 60 * 1000; // Only attempt to fetch product versions for one minute total // Cache available versions in memory for 1 hour const CACHE_DURATION = 1000 * 60 * 60; @@ -119,7 +120,10 @@ async function fetchAgentVersionsFromApi() { }; try { - const response = await pRetry(() => fetch(PRODUCT_VERSIONS_URL, options), { retries: 1 }); + const response = await pRetry(() => fetch(PRODUCT_VERSIONS_URL, options), { + retries: 1, + maxRetryTime: MAX_REQUEST_TIMEOUT, + }); const rawBody = await response.text(); // We need to handle non-200 responses gracefully here to support airgapped environments where