preview demo: drop a stored login for another server before the app reads it #80
Loading…
Reference in a new issue
No description provided.
Delete branch "void/demo-homeserver-unreachable"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Root cause
All previews of this site share the origin minds.gamecult.org, so they share one localStorage. A login another preview left there (
cinny_hs_base_url= a real homeserver, plus token, user id and device id) is read by the demo build viagetFallbackSession; the app then loads that server's spec versions,guardedFetchrefuses every non-demo origin, andSpecVersionsshows "Unable to connect to the homeserver".Reproduced on Starfire (headless Chrome, desktop 1920x1080 and phone 390x844@2x) against the live https://minds.gamecult.org/void/rat-dev-66c4c637/ with localStorage pre-seeded as another preview would leave it (cinny_hs_base_url=https://chat.gamecult.org): the dialog appears, with
PAGEERROR TypeError: preview: pretend server only; fetch to https://chat.gamecult.org/_matrix/client/versions refused.It reproduced with a clean service-worker state, with an already registered service worker, and at both viewports. Clean profile: login and sign-in to the room list work. A stored demo session (base https://demo.invalid): lands on the room list, no error. A stale service worker is not the cause (each preview registers its own subpath scope; the foreign case fails with or without one). The pretend server answers /versions fine, and config.json/hashRouter/subpath handling are fine.
Fix
installDemo(src/preview-demo/install.ts) callsdropForeignSessionfirst: a stored login whose base URL is not the demo origin is removed before the app reads it. The earlier banner text for a foreign session is deleted (the state it described can no longer exist). In src/index.tsx the service worker is registered after the demo has settled storage, so the worker is never handed the dropped session.getFallbackSession/removeFallbackSessiontake an optional Storage (default localStorage) so the rule is testable.Tests
src/preview-demo/server.test.ts:
dropForeignSessionremoves a real-homeserver session and nothing else, keeps the demo session;installDemoover a stored foreign login leaves storage empty. Fullnpx vitest run: 49 files, 708 tests pass.vite build(VITE_PREVIEW_DEMO=1) passes.Starfire results (scratch build /void/rat-demo-repro-b5449936/)
Per viewport (desktop and phone), all of: clean, foreign session, demo session, SW registered first, foreign session after SW warm-up (a sixth state in the script, "no prior SW", was identical to the foreign one). Every state without a stored demo session reaches the login screen and demo sign-in reaches the room list (GameCult / General / Commons / Projects / DMs); the demo-session state goes straight to the room list. No "Unable to connect" in any. Console: only the known OIDC issuer errors. Before the fix the three foreign states showed the dialog at both viewports.
Not checked
Real touch, a real person's browser with other profile state (IndexedDB sync stores from a real build are untouched; only the four session keys are dropped). Symmetric hazard left alone: a demo visit leaves cinny_hs_base_url=https://demo.invalid, which a real-homeserver preview on the same origin will read and fail on; that needs its own fix in the real build, not here.
🤖 Generated with Claude Code