Fetch console data in parallel with the WASM validator#941
Conversation
🤖 Claude Code ReviewPR: #941 The change is well-scoped and I've verified the logic. Here is my review. Code Review: Fetch console data in parallel with the WASM validatorSummaryRemoves CorrectnessThe reactivity model is sound and the parallelism is achieved correctly:
Points worth noting (minor)
Standards compliance (CLAUDE.md)
Security & Performance
VerdictApprove. Clean, well-tested refactor that does what it claims. Consider (a) whether the malformed-stored-token → server-401 path needs the old silent-skip UX, and (b) applying the same treatment to the remaining deck-card fetchers if that was in scope. I did not run the Vitest suite ( Model: claude-opus-4-8 |
Data fetchers across the console's hot pages gated their request on the bencher_valid WASM validator being initialized, only so they could run a client-side JWT format pre-check. That serialized every fetch behind WASM init on a fresh page load instead of letting the request and the WASM download run in parallel. Remove bencher_valid from the fetch gate in the perf panel, table panel, deck panel, pinned plot, plots panel, and perf frame. The request now fires at mount, and the WASM-based JWT format check runs only once the validator has loaded (best-effort). Each site keeps its own auth semantics (token optional, token required, or console only), and the server validates the token regardless. Extract the shared best-effort check into jwtRequiredInvalid and jwtOptionalInvalid helpers in util/valid.ts, with unit tests, so the policy lives in one place.
f171927 to
e092101
Compare
Problem
On a fresh page load, data fetchers across the console's hot pages block their request on the
bencher_validWASM validator being initialized, only so they can run a client-side JWT format pre-check. The token is validated by the server regardless, so this serializes every fetch behind WASM init instead of letting the request and the WASM download run in parallel.Change
Remove
bencher_validfrom the fetch gate in the hot data-path panels and fire the request at mount instead:PerfPanel(the sharedgetSelectedandgetPerfTabfetchers)PerfFrame,PlotsPanel(perf + plots)TablePanel,DeckPanel,PinnedPlotThe WASM-based JWT format check now runs only once the validator has loaded (best-effort). Each site keeps its own auth semantics:
fetcher.token && bencher_valid() && !validJwt(token)!fetcher.token || (bencher_valid() && !validJwt(token))props.isConsole && (!fetcher.token || (bencher_valid() && !validJwt(token)))The
bencher_valid()resource is still created in every file, so the WASM validator still loads for other uses.Cold paths (onboarding, billing, auth, redirects) are intentionally left unchanged.
Testing
biome formatandbiome lintclean.Note
This is a latency optimization on the page-refresh path. In practice WASM init overlaps hydration, so the win is modest (largest on a cold asset cache); the change also removes an unnecessary coupling of every data fetch to the validation module.