Repository navigation
fix(query-cache): keep game data in memory when the IndexedDB cache fails - #555
Merged
Merged
Conversation
…ails - storeAndPreload falls back to the in-memory layer (new useDB fill) when the IndexedDB write or read-back throws, so the query resolves with the API data instead of failing - getDB reopens after the browser force-closes the connection (terminated) or after a failed open; storeAndPreload drops the connection on InvalidStateError / UnknownError so a silently lost one reopens too - setMany awaits every request with tx.done, so an aborted transaction (e.g. quota) rejects once instead of leaving unhandled rejections - tests for the fallback, upsert vs. replace, reconnects and the abort path; data-layer docs updated Closes #549 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ Deploy Preview for prunplanner-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 6 |
| Duplication | 0 |
🟢 Coverage 100.00% diff coverage · +0.01% coverage variation
Metric Results Coverage variation ✅ +0.01% coverage variation (-1.00%) Diff coverage ✅ 100.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (f0cad6e) 3703 3613 97.57% Head commit (36c5292) 3714 (+11) 3624 (+11) 97.58% (+0.01%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#555) 20 20 100.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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.
What and why
When the browser closes the IndexedDB connection (site data cleared, eviction) or storage is full, every game-data query failed even though the API returned valid data, and plan pages showed a failed loader step until reload (PostHog:
InvalidStateError: … connection is closing,QuotaExceededError). The cache is an optimisation, so a broken cache must never fail a query.Changes
storeAndPreloadfalls back to the in-memory layer (newuseDB().fill(rows, replace)) when the IndexedDB write or read-back throws, so the query resolves with the API data. Planet queries (no wipe) upsert into the rows already loaded; full lists replace them.getDBreopens after the browser force-closes the connection (terminated) or after a failed open.storeAndPreloadalso drops the connection onInvalidStateError/UnknownError(WebKit's lost connection), so one lost without acloseevent reopens too.setManyawaits every request together withtx.done, so an aborted transaction (e.g. quota) rejects once instead of producing an unhandled rejection per row.docs/data-layer.mdupdated.How it was verified
pnpm test && pnpm tsc && pnpm lint && pnpm knip: all pass.Closes #549
🤖 Generated with Claude Code