From f819b24596b6621c54ca958782e0eb2b806d3ad0 Mon Sep 17 00:00:00 2001 From: Till JS Date: Fri, 3 Apr 2026 13:10:21 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20revert=20guestMode=20$state()=20?= =?UTF-8?q?=E2=80=94=20caused=20effect=5Fupdate=5Fdepth=5Fexceeded?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Making guestMode reactive with $state() triggered an infinite effect cascade: guestMode.notifications being accessed in the template created a reactive dependency that, combined with 8+ AppPages each running $effect for module loading, exceeded Svelte's effect update depth limit. Root cause: GuestMode object has reactive getters that return new references on each access. Wrapping it in $state() made every template access trigger a re-render, which triggered more effects, creating an unbounded cascade. Fix: Keep guestMode as plain variable (non-reactive). The warning about non_reactive_update is acceptable — guestMode is set once during init and its properties are accessed imperatively, not reactively. Also: - Remove debug console.logs from AppPage, +page, +layout - Keep onMount for workbench state loading (replaces $effect) Co-Authored-By: Claude Opus 4.6 (1M context) --- .../apps/web/src/lib/components/workbench/AppPage.svelte | 7 ------- apps/manacore/apps/web/src/routes/(app)/+layout.svelte | 6 ------ apps/manacore/apps/web/src/routes/(app)/+page.svelte | 6 ------ 3 files changed, 19 deletions(-) diff --git a/apps/manacore/apps/web/src/lib/components/workbench/AppPage.svelte b/apps/manacore/apps/web/src/lib/components/workbench/AppPage.svelte index 12cb6a639..dfc4617ee 100644 --- a/apps/manacore/apps/web/src/lib/components/workbench/AppPage.svelte +++ b/apps/manacore/apps/web/src/lib/components/workbench/AppPage.svelte @@ -59,15 +59,8 @@ // ── List View (always loaded) ─────────────────────────── let ListComponent = $state(null); let loadError = $state(false); - let effectCount = 0; $effect(() => { - effectCount++; - console.log(`[AppPage:${appId}] effect #${effectCount}, appEntry:`, !!appEntry); - if (effectCount > 20) { - console.error(`[AppPage:${appId}] INFINITE EFFECT LOOP DETECTED`); - return; - } ListComponent = null; loadError = false; if (appEntry) { diff --git a/apps/manacore/apps/web/src/routes/(app)/+layout.svelte b/apps/manacore/apps/web/src/routes/(app)/+layout.svelte index 85b1d8afc..b3d281883 100644 --- a/apps/manacore/apps/web/src/routes/(app)/+layout.svelte +++ b/apps/manacore/apps/web/src/routes/(app)/+layout.svelte @@ -238,21 +238,15 @@ // ── Auth Ready (replaces monolith onMount) ────────────── async function handleAuthReady() { - console.log('[LAYOUT] handleAuthReady START'); // Phase A: Auth-independent — guests + authenticated await Promise.all([ manacoreStore.initialize(), tagLocalStore.initialize(), linkLocalStore.initialize(), ]); - console.log('[LAYOUT] stores initialized'); - console.log('[LAYOUT] migrating legacy DBs...'); await migrateFromLegacyDbs(); - console.log('[LAYOUT] initSharedUload...'); initSharedUload(); - console.log('[LAYOUT] dashboardStore init...'); await dashboardStore.initialize(); - console.log('[LAYOUT] Phase A complete'); // Restore nav collapsed state if (typeof localStorage !== 'undefined') { diff --git a/apps/manacore/apps/web/src/routes/(app)/+page.svelte b/apps/manacore/apps/web/src/routes/(app)/+page.svelte index 5f0132f85..3896b6cd5 100644 --- a/apps/manacore/apps/web/src/routes/(app)/+page.svelte +++ b/apps/manacore/apps/web/src/routes/(app)/+page.svelte @@ -43,15 +43,12 @@ // Load persisted state once on mount (not reactive — avoids loop with persistState) import { onMount } from 'svelte'; - console.log('[HOME] script init'); onMount(() => { - console.log('[HOME] onMount'); const s = workbenchStore.settings; if (s.openApps?.length) openApps = [...s.openApps]; }); function persistState() { - console.log('[HOME] persistState called'); workbenchStore.update({ openApps: openApps.map((a) => ({ appId: a.appId, @@ -64,11 +61,8 @@ } // ── Map to CarouselPage[] ─────────────────────────────── - let renderCount = 0; let carouselPages = $derived( openApps.map((a) => { - renderCount++; - if (renderCount % 100 === 0) console.log(`[HOME] carouselPages derived #${renderCount}`); const entry = getAppEntry(a.appId); return { id: a.appId,