Skip to content

Commit

Permalink
Retry pom reading; do not let maven errors break the build
Browse files Browse the repository at this point in the history
  • Loading branch information
holly-cummins committed Feb 22, 2024
1 parent ffeac64 commit a892a89
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions src/maven/maven-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}

}
Expand Down

0 comments on commit a892a89

Please sign in to comment.