From a892a89fc36af796706b8ef42bd0930e6583bcdd Mon Sep 17 00:00:00 2001 From: Holly Cummins Date: Thu, 22 Feb 2024 13:54:13 +0000 Subject: [PATCH] Retry pom reading; do not let maven errors break the build --- src/maven/maven-info.js | 45 +++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/maven/maven-info.js b/src/maven/maven-info.js index cfff27fb9691..070fed4e7ab5 100644 --- a/src/maven/maven-info.js +++ b/src/maven/maven-info.js @@ -122,8 +122,6 @@ const generateMavenInfo = async artifact => { maven.url = mavenUrl } - // - const latestVersion = await latestVersionCache.getOrSet(artifact, () => tolerantlyGetLatestVersionFromMavenSearch(maven)) // If the latest version of an artifact is also its current version, there's unlikely to be a relocation on it if (latestVersion && latestVersion !== maven.version) { @@ -133,29 +131,36 @@ const generateMavenInfo = async artifact => { version: latestVersion }) - const data = await latestVersionCache.getOrSet(latestPomUrl, async () => { - const options = { - retries: 6, - factor: 3, - minTimeout: 4 * 1000, + const options = { + retries: 6, + factor: 3, + minTimeout: 4 * 1000, + } + + try { + const data = await latestVersionCache.getOrSet(latestPomUrl, async () => { + const response = await promiseRetry(async () => axios.get(latestPomUrl, {}), options) + return response.data } - const response = await promiseRetry(async () => axios.get(latestPomUrl, {}), options) - return response.data - } - ) + ) - const processed = await readPom(data) + if (data) { + const processed = await promiseRetry(async () => readPom(data), options) - maven.relocation = processed.relocation + maven.relocation = processed.relocation - // Sometimes a relocation stanza might be missing a group id or artifact id, so fill in gaps - if (maven.relocation) { - if (!maven.relocation.artifactId) { - maven.relocation.artifactId = maven.artifactId - } - if (!maven.relocation.groupId) { - maven.relocation.groupId = maven.groupId + // Sometimes a relocation stanza might be missing a group id or artifact id, so fill in gaps + if (maven.relocation) { + if (!maven.relocation.artifactId) { + maven.relocation.artifactId = maven.artifactId + } + if (!maven.relocation.groupId) { + maven.relocation.groupId = maven.groupId + } + } } + } catch (error) { + console.warn("Tried to read", latestPomUrl, "Error made it through the promise retry", error) } }