fix(nuxt): ignore fetch errors in getLatestManifest (#26486)

This commit is contained in:
Michał Zarach 2024-03-26 14:47:59 +01:00 committed by GitHub
parent 67c664656c
commit 1dbd46ec99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,10 +14,14 @@ export default defineNuxtPlugin((nuxtApp) => {
const currentManifest = await getAppManifest()
if (timeout) { clearTimeout(timeout) }
timeout = setTimeout(getLatestManifest, 1000 * 60 * 60)
const meta = await $fetch<NuxtAppManifestMeta>(buildAssetsURL('builds/latest.json') + `?${Date.now()}`)
if (meta.id !== currentManifest.id) {
// There is a newer build which we will let the user handle
nuxtApp.hooks.callHook('app:manifest:update', meta)
try {
const meta = await $fetch<NuxtAppManifestMeta>(buildAssetsURL('builds/latest.json') + `?${Date.now()}`)
if (meta.id !== currentManifest.id) {
// There is a newer build which we will let the user handle
nuxtApp.hooks.callHook('app:manifest:update', meta)
}
} catch {
// fail gracefully on network issue
}
}