Skip to content

Fetch console data in parallel with the WASM validator#941

Draft
epompeii wants to merge 1 commit into
develfrom
u/ep/parallel-data-fetch
Draft

Fetch console data in parallel with the WASM validator#941
epompeii wants to merge 1 commit into
develfrom
u/ep/parallel-data-fetch

Conversation

@epompeii

Copy link
Copy Markdown
Member

Problem

On a fresh page load, data fetchers across the console's hot pages block their request on the bencher_valid WASM 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_valid from the fetch gate in the hot data-path panels and fire the request at mount instead:

  • PerfPanel (the shared getSelected and getPerfTab fetchers)
  • PerfFrame, PlotsPanel (perf + plots)
  • TablePanel, DeckPanel, PinnedPlot

The WASM-based JWT format check now runs only once the validator has loaded (best-effort). Each site keeps its own auth semantics:

  • token optional: fetcher.token && bencher_valid() && !validJwt(token)
  • token required: !fetcher.token || (bencher_valid() && !validJwt(token))
  • console only: 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 format and biome lint clean.
  • Manually verified on a local dev build (logged in): the perf page renders a full chart with all dimension tabs, the branches table lists data, and a branch detail page loads, all with no console errors.

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.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

🤖 Claude Code Review

PR: #941
Base: devel
Head: u/ep/parallel-data-fetch
Commit: e0921015ce963617c5f6e3f901cd2d2d7f39ef89


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 validator

Summary

Removes bencher_valid() from the SolidJS resource source memos (so data fetches no longer block on WASM init) and moves the validity check inside the async fetcher via two new best-effort helpers, jwtRequiredInvalid / jwtOptionalInvalid. This lets the HTTP request and the WASM download proceed in parallel. Net win for perceived latency.

Correctness

The reactivity model is sound and the parallelism is achieved correctly:

  • Reading bencher_valid() inside the async fetcher body (second arg to createResource) is untracked in SolidJS, so the fetch fires on token/query changes without waiting for WASM. This is exactly the intended behavior.
  • The short-circuit !!valid && !validJwt(token) correctly ensures the WASM-backed is_valid_jwt is only invoked after the validator has loaded, preserving the old guard against calling WASM before init.
  • The truth tables check out:
    • jwtRequiredInvalid: skips on missing token (unchanged), or malformed token once WASM loads; lets present/well-formed (or pre-WASM) tokens through.
    • jwtOptionalInvalid: allows missing token (public access), only rejects a present+malformed token after WASM loads.
  • The helpers are directly unit-tested across all four state combinations (validator loaded/not × token missing/present/malformed), matching the documented semantics. Good TDD coverage.

Points worth noting (minor)

  1. Behavior change for malformed stored tokens. Previously a corrupted token in storage was caught client-side (fetch waited for WASM, then returned empty). Now, if the fetch fires before WASM loads, jwtRequiredInvalid(undefined, malformedToken) returns false, so the bad token is sent to the server and yields a 401 (and an error pageNotify toast in DeckPanel/TablePanel). The comments acknowledge "the server validates the token regardless," and there is no refetch when WASM later loads (the source no longer depends on bencher_valid), so the request is not retried. This is an acceptable trade-off given malformed stored tokens are pathological, but it is a real semantic change worth being deliberate about. No action required unless you want the error UX preserved.

  2. Inconsistent application of the optimization. The same bencher_valid: bencher_valid()-in-source pattern that this PR removes still exists in sibling fetchers that would benefit equally, e.g. deck/hand/card/ThresholdTableCard.tsx, deck/hand/card/ReportTableCard.tsx, navbar/ProjectsLink.tsx, and the billing/onboard panels. If deferring those was intentional (scope), fine; otherwise the deck cards in particular render alongside DeckPanel and still gate on WASM.

Standards compliance (CLAUDE.md)

  • No emdashes in comments/copy. ✔
  • SolidJS reactivity patterns used correctly. ✔
  • Tests included and colocated (valid.wasm.test.ts), gated with describe.skipIf(!wasmReady). ✔
  • Strong typing preserved (InitValid, no stringly-typed regressions). ✔

Security & Performance

  • No security regression: the server remains the authority on token validation; the client check was always a best-effort UX gate. The !!valid && guard prevents unguarded WASM calls.
  • Performance: net positive; removes an artificial serialization between WASM init and the first data fetch on every affected panel.

Verdict

Approve. 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 (npm run setup && vitest) in this review; the logic and test assertions were verified by inspection.


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.
@epompeii
epompeii force-pushed the u/ep/parallel-data-fetch branch from f171927 to e092101 Compare July 14, 2026 05:19
@epompeii epompeii self-assigned this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant