refactor: harden SQLite delegate cache and address review feedback#41
Open
fionnachan wants to merge 1 commit intomainfrom
Open
refactor: harden SQLite delegate cache and address review feedback#41fionnachan wants to merge 1 commit intomainfrom
fionnachan wants to merge 1 commit intomainfrom
Conversation
Follow-up to #39 with review fixes plus two bugs found during dev testing. Routing and caching: - s-maxage + SWR replaces browser-only Cache-Control + force-dynamic so Vercel's edge cache actually serves range responses. - GET/HEAD wrapped in try/catch; surface 502/503 instead of bare 500. - Production throws when no blob env var is set; default URL is a dev-only fallback. - Stay on runtime=nodejs (Next's edge dev server stomps the explicit HEAD Content-Length, which breaks sql.js-httpvfs file-size discovery). Public-file conflict (fix: 500s on /delegates): - SQLite build output moves from public/tally-data/ to data/build/ so the static asset no longer shadows the proxy route. Manifest stays in public/. Manifest-driven config: - manifest.json gains schemaVersion, cacheBust, totalVotingPower. - Route and client read sizes/URLs from the manifest at runtime. - Deploy script no longer regex-rewrites constants in three sources. Total voting power correctness: - delegate_list threshold lowered from 10 ARB to 1 ARB. - Total ships in the manifest; client reads it instead of summing the filtered SQL rows, so the figure no longer collapses when the user raises the display-side minimum-power filter. - RPC refresh applies a delta to the existing total instead of resumming the visible subset. - 5000 ARB UI floor pushed into SQL. SQLite client hardening: - workerPromise resets on init rejection so callers can retry. - Stale tally-zero:sqlite:* localStorage keys swept on first load. - Always-zero lastChangeBlock field dropped. Module split: - lib/delegate-cache.ts -> delegate-rank-cache.ts (gov-tracker) + delegate-data.ts (SQLite). All callers migrated. Misc: - ElectionPageClient: useMemo side effect -> useState initializer. - avatar-map.json removed from git; build warns when missing and points at pnpm avatars:upload. - README "Data layer" section. - Playwright config + delegates smoke test, pnpm e2e script. - Route tests cover cache header, 502/503 paths, env-var guard. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #39 with review fixes plus two bugs found during dev testing.
Routing and caching:
Public-file conflict (fix: 500s on /delegates):
Manifest-driven config:
Total voting power correctness:
SQLite client hardening:
Module split:
Misc: