lotusFlag/lotusParam URL cache is captured once at module load, not re-read #33

Closed
opened 2026-09-12 02:13:15 -04:00 by jared · 0 comments
Owner

Severity: low · Type: tech-debt · Confidence: medium

Location: src/lotus/lotusWidget.ts:24-42

Problem

lotusParam memoizes cachedParams in a module-level variable on first call and never invalidates it. useTheme's useLayoutEffect (which calls lotusFlag) re-runs on every requestedTheme change (i.e., every host ThemeChange action), but it will keep returning whatever lotusTransparent/lotusTheme value was present in location.hash/search at the very first call, even if EC's HashRouter has since rewritten location.hash for navigation (lobby → in-call) in a way that drops or reorders the query portion. This wasn't verified to actually lose the flag in this fork's router config (the params are seeded before mount in the observed flow), but the caching pattern is a latent staleness trap if that assumption ever changes.

How to trigger

Would require a case where the hash's query string is rebuilt without carrying the original lotusTransparent/lotusTheme params forward during in-iframe navigation.

Suggested fix

Re-derive from window.location on each call (params are lightweight to parse) or invalidate the cache on popstate/hashchange, so a defensive fix costs little and removes the latent risk.


Filed from the September 2026 audit (branch lotus).

**Severity:** low · **Type:** tech-debt · **Confidence:** medium **Location:** `src/lotus/lotusWidget.ts:24-42` ### Problem `lotusParam` memoizes `cachedParams` in a module-level variable on first call and never invalidates it. `useTheme`'s `useLayoutEffect` (which calls `lotusFlag`) re-runs on every `requestedTheme` change (i.e., every host `ThemeChange` action), but it will keep returning whatever `lotusTransparent`/`lotusTheme` value was present in `location.hash`/`search` at the very first call, even if EC's `HashRouter` has since rewritten `location.hash` for navigation (lobby → in-call) in a way that drops or reorders the query portion. This wasn't verified to actually lose the flag in this fork's router config (the params are seeded before mount in the observed flow), but the caching pattern is a latent staleness trap if that assumption ever changes. ### How to trigger Would require a case where the hash's query string is rebuilt without carrying the original `lotusTransparent`/`lotusTheme` params forward during in-iframe navigation. ### Suggested fix Re-derive from `window.location` on each call (params are lightweight to parse) or invalidate the cache on `popstate`/`hashchange`, so a defensive fix costs little and removes the latent risk. --- --- _Filed from the September 2026 audit (branch `lotus`)._
jared added this to the EC fork audit 2026-09 · Medium & Low milestone 2026-09-12 02:13:15 -04:00
jared added the priority: lowtech-debtarea: mobile-ui labels 2026-09-12 02:13:15 -04:00
jared self-assigned this 2026-09-12 02:13:15 -04:00
jared closed this issue 2026-09-13 01:22:58 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/element-call#33