mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 23:16:21 +00:00
c35a2d4b4f
The snapshot hooks were chained against renderer Manager methods (getUserDataSnapshot, getIgnoredUsersSnapshot, subscribe, …) under the assumption that the resolved \`@nitrots/nitro-renderer\` bundle always includes the v2.1.0+ snapshot API. That assumption fails in two real scenarios: 1. A stale \`dist/index.js\` shadows the source umbrella at resolution time (the vite alias commit790ad2bmitigates this in dev, but it only takes effect after a server restart). 2. A consumer bundles the client against an older renderer release (e.g. NitroV3-Housekeeping's embedded copy in \`public/nitro3\`). In both cases the snapshot hook calls \`undefined()\` and React shows the error-boundary fallback "(intermediate value)() is undefined". Wrap every renderer-side call with a typeof guard: const manager = GetSessionDataManager(); if(!manager || typeof manager.getUserDataSnapshot !== 'function') return DEFAULT_USER_DATA; return manager.getUserDataSnapshot(); Module-level frozen defaults (DEFAULT_USER_DATA, EMPTY_IGNORED_LIST, EMPTY_GROUP_BADGES, EMPTY_USER_LIST, DEFAULT_VOLUMES, NOOP_UNSUBSCRIBE) keep the snapshot reference stable across fallback calls, so useSyncExternalStore's bailout still works and we don't trigger render loops on the degraded path. Once the renderer is upgraded (or the alias kicks in after restart), the hooks transparently switch to the real getters — no code change needed at any consumer. Verification: yarn typecheck clean, yarn test 207/207, yarn build green. The fix is defense-in-depth on top of790ad2b(vite alias) — both can coexist, neither alone is sufficient for every deployment surface.