From 4519c09c1818cec5cc0194fefa3c56f58c42fcb9 Mon Sep 17 00:00:00 2001 From: Richard Petersen <richard.petersen@open-xchange.com> Date: Wed, 9 Feb 2022 17:24:46 +0100 Subject: [PATCH] Fix: OXUIB-1289 - UI-Middleware breaks if UI-Containers are not available Root cause: If some of the UI containers is not available after successful start, the version update check might fail. Solution: Add error handlers when manifests can not be fetched after startup --- src/createApp.js | 2 ++ src/manifests.js | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/createApp.js b/src/createApp.js index be8e0e9..036dd3e 100644 --- a/src/createApp.js +++ b/src/createApp.js @@ -41,6 +41,8 @@ export function createApp () { const stopTimer = startUpTimeGauge.startTimer() try { const viteManifests = await loadViteManifests() + // also need to load ox manifests here, to make sure the cache is warm + await getOxManifests() const deps = viteManifestToDeps(viteManifests) await fileCache.warmUp(viteManifests, deps) } catch (e) { diff --git a/src/manifests.js b/src/manifests.js index cc608c6..07c6174 100644 --- a/src/manifests.js +++ b/src/manifests.js @@ -96,8 +96,8 @@ export const getOxManifests = (() => { let prevHash let oxManifestCache return async function getOxManifests () { - const viteManifest = await loadViteManifests() - if (viteManifest.__hash__ !== prevHash) { + const viteManifest = await loadViteManifests().catch(() => {}) + if (viteManifest && viteManifest.__hash__ !== prevHash) { oxManifestCache = viteToOxManifest(viteManifest) prevHash = viteManifest.__hash__ } @@ -124,8 +124,9 @@ export const getDependencies = (() => { let prevHash let depCache return async function getDependencies () { - const viteManifest = await loadViteManifests() - if (viteManifest.__hash__ !== prevHash) { + // simply catch the error here. This might happen, when one of the UI containers is temporarily not available + const viteManifest = await loadViteManifests().catch(() => {}) + if (viteManifest && viteManifest.__hash__ !== prevHash) { depCache = viteManifestToDeps(viteManifest) prevHash = viteManifest.__hash__ } @@ -143,8 +144,8 @@ export const getVersion = (() => { let prevHash let versionString return async function getVersion () { - const viteManifest = await loadViteManifests() - if (viteManifest.__hash__ !== prevHash) { + const viteManifest = await loadViteManifests().catch(() => {}) + if (viteManifest && viteManifest.__hash__ !== prevHash) { versionString = `${+new Date()}.${viteManifest.__hash__}` prevHash = viteManifest.__hash__ } -- GitLab