Skip to content
Snippets Groups Projects
Commit fb0a2f4c authored by andree.klattenhoff's avatar andree.klattenhoff
Browse files

Improve logging if fetch for manifest.json/meta.json failed

parent b9a3881e
No related branches found
No related tags found
No related merge requests found
...@@ -45,8 +45,15 @@ export const versionUpdateGauge = new Gauge({ ...@@ -45,8 +45,15 @@ export const versionUpdateGauge = new Gauge({
export async function fetchVersionInfo () { export async function fetchVersionInfo () {
const versions = await Promise.all(configMap.urls.map(async baseUrl => { const versions = await Promise.all(configMap.urls.map(async baseUrl => {
try { try {
const response = await fetch(new URL('meta.json', baseUrl), { cache: 'no-store' }) const response = await fetch(new URL('meta.json', baseUrl), { cache: 'no-store' }).catch((err) => {
if (!response.ok) throw new Error() logger.error(err)
logger.warn(`[Version] Failed to load meta.json from UI container at ${baseUrl}.`)
throw new Error()
})
if (!response.ok) {
logger.warn(`[Version] Failed to load meta.json from ${response.url} (Status: ${response.status}: ${response.statusText})`)
throw new Error()
}
if (response.headers.get('version')) return response.headers.get('version') if (response.headers.get('version')) return response.headers.get('version')
...@@ -55,10 +62,18 @@ export async function fetchVersionInfo () { ...@@ -55,10 +62,18 @@ export async function fetchVersionInfo () {
if (!version) throw new Error() if (!version) throw new Error()
return version return version
} catch (err) { } catch (err) {
logger.warn(`[Version] UI container at ${baseUrl} does not have meta.json. Fall back to version hash based on manifest.`) logger.warn('[Version] Fall back to version hash based on manifest.')
}
const response = await fetch(new URL('manifest.json', baseUrl), { cache: 'no-store' }).catch((err) => {
logger.error(err)
logger.warn(`[Version] Failed to load manifest.json from UI container at ${baseUrl}.`)
throw new Error(`Cannot fetch manifest.json from ${baseUrl}`)
})
if (!response.ok) {
logger.warn(`[Version] Failed to load manifest.json from ${response.url} (Status: ${response.status}: ${response.statusText})`)
throw new Error(`Cannot fetch manifest.json from ${baseUrl}`)
} }
const response = await fetch(new URL('manifest.json', baseUrl), { cache: 'no-store' })
if (!response.ok) throw new Error(`Cannot fetch manifest.json from ${baseUrl}`)
const manifest = await response.json() const manifest = await response.json()
return hash(manifest) return hash(manifest)
})) }))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment