Skip to content

fix: bust persisted query cache on deploy - #2058

Open
alanpeixinho wants to merge 1 commit into
kernelci:mainfrom
profusion:fix/frontend-stale-cache
Open

fix: bust persisted query cache on deploy#2058
alanpeixinho wants to merge 1 commit into
kernelci:mainfrom
profusion:fix/frontend-stale-cache

Conversation

@alanpeixinho

Copy link
Copy Markdown
Contributor

What it is

Fixes /tree crashing with Cannot read properties of undefined (reading 'map') when a persisted React Query cache holds an origins payload without checkout_origins / test_origins (#2048).

  • OriginSelect treats missing origin lists as [] so .map cannot throw.
  • Persist cache is versioned with VITE_CACHE_BUSTER (dashboard version, or build-<timestamp> if empty) so a new deploy drops stale blobs.

How to test

Dev persist uses sessionStorage (prod: localStorage). Recover with sessionStorage.clear() then reload.

  1. Open /tree and confirm the origin dropdown works.
  2. Seed a mismatched origins shape and reload:
sessionStorage.setItem('REACT_QUERY_OFFLINE_CACHE', JSON.stringify({
buster: '', timestamp: Date.now(),
clientState: { mutations: [], queries: [{
  queryKey: ['origins'], queryHash: '["origins"]',
  state: { data: ['maestro'], dataUpdatedAt: Date.now(), status: 'success', fetchStatus: 'idle' },
}]},
}));
location.reload();

Expect: no “Something went wrong!”; origins refetch; dropdown populated.
3. Confirm stored buster matches the side-menu version (or build-… if no version).
4. Reload without editing the cache: same buster → hydrates, no crash.

Closes #2048

- Guard pageOrigins so a mismatched origins shape cannot crash /tree
- Version the persist buster so stale cache blobs are dropped on deploy

Closes kernelci#2048
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Listing page crashes with "Cannot read properties of undefined (reading 'map')"

1 participant