From 86726e3dfcfc576b3096570d5f074f77e38446b3 Mon Sep 17 00:00:00 2001 From: Hanzo_dev <2002samudiojohan@gmail.com> Date: Thu, 26 Feb 2026 11:05:43 -0500 Subject: [PATCH] fix(pwa): completely destroy service worker cache and fix chunk load errors to stop freezing --- frontend/src/router/index.ts | 7 +++++++ frontend/src/views/SplashScreen.vue | 11 +++-------- frontend/vite.config.ts | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index c60f79e..ff22e0c 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -181,4 +181,11 @@ router.beforeEach(async (to, _from, next) => { next() }) +router.onError((error, to) => { + // Si falla la carga de un chunk (al actualizar la app), recarga la página para obtener la última versión + if (error.message.includes('Failed to fetch dynamically imported module') || error.message.includes('Importing a module script failed')) { + window.location.href = to.fullPath + } +}) + export default router diff --git a/frontend/src/views/SplashScreen.vue b/frontend/src/views/SplashScreen.vue index bd5bb64..0a2a176 100644 --- a/frontend/src/views/SplashScreen.vue +++ b/frontend/src/views/SplashScreen.vue @@ -45,15 +45,10 @@ onMounted(async () => { loadingVisible.value = true // Timeout logic - const initTimeout = setTimeout(async () => { + const initTimeout = setTimeout(() => { console.warn('Initialization taking too long, forcing navigation...') - statusMessage.value = 'Iniciando de todas formas...' - try { - const resp = await supabase.auth.getSession() - navigate(resp.data.session) - } catch { - navigate() - } + statusMessage.value = 'Iniciando modo sin conexión...' + router.replace('/map') }, 4000) try { diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 73b0b24..54b70a1 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -11,6 +11,7 @@ export default defineConfig(() => { vue(), tailwindcss(), VitePWA({ + selfDestroying: true, registerType: 'autoUpdate', includeAssets: ['icon-192.png', 'icon-512.png', 'icon-1024.png', 'favicon.ico'], manifest: {