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() const currentManifest = await getAppManifest()
if (timeout) { clearTimeout(timeout) } if (timeout) { clearTimeout(timeout) }
timeout = setTimeout(getLatestManifest, 1000 * 60 * 60) timeout = setTimeout(getLatestManifest, 1000 * 60 * 60)
const meta = await $fetch<NuxtAppManifestMeta>(buildAssetsURL('builds/latest.json') + `?${Date.now()}`) try {
if (meta.id !== currentManifest.id) { const meta = await $fetch<NuxtAppManifestMeta>(buildAssetsURL('builds/latest.json') + `?${Date.now()}`)
// There is a newer build which we will let the user handle if (meta.id !== currentManifest.id) {
nuxtApp.hooks.callHook('app:manifest:update', meta) // 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
} }
} }