Skip to content

Commit

Permalink
Add max request timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
kpollich committed Dec 7, 2023
1 parent 52978a9 commit 7970453
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion x-pack/plugins/fleet/server/services/agents/versions.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7970453

Please sign in to comment.