fix(client): stop ExpiredShapesCache writing to localStorage on every read - #4799
Merged
kevin-dp merged 1 commit intoSep 8, 2026
Merged
Conversation
… read getExpiredHandle is a read accessor that also persisted the whole cache, and it runs while building the URL of every shape request. In live mode that is a full JSON.stringify plus localStorage.setItem once per poll, indefinitely. lastUsed is still updated in memory, and markExpired reads it from memory when picking an eviction candidate, so LRU ordering within a session is unchanged. After a reload the persisted values reflect the last markExpired rather than the last read, so eviction order at the 250-entry cap can be staler.
PepijnSenders
force-pushed
the
fix/expired-shapes-cache-read-write
branch
from
September 7, 2026 21:42
8ea9aa2 to
88b7508
Compare
kevin-dp
approved these changes
Sep 8, 2026
kevin-dp
left a comment
Contributor
There was a problem hiding this comment.
Great, thanks for spotting this and fixing it!
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4799 +/- ##
===========================================
+ Coverage 60.04% 71.59% +11.55%
===========================================
Files 397 70 -327
Lines 43773 8975 -34798
Branches 12592 2848 -9744
===========================================
- Hits 26283 6426 -19857
+ Misses 17409 2531 -14878
+ Partials 81 18 -63
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
closes #4795
why the change
any electric app in a webkit webview grows localStorage forever while it's open — our tauri app hit a 4.2gb wal next to a 49kb db after three days, 736mb on macos.
getExpiredHandleis a read accessor that persists the whole cache, and it runs on every shape request, so a live stream writes once per poll. webkit never checkpoints the wal while the process lives, so nothing reclaims it.special things to note
lastUsedstill updates in memory, so lru order within a session is unchanged; only eviction order after a reload can be stalershould not accept expired handle from stale cached response after 409change outline
the write leaves the read path
ExpiredShapesCache.getExpiredHandle(shapeUrl) └─ if (entry) ├─ Date.now() - └─ ExpiredShapesCache.save() - ├─ if (typeof localStorage === `undefined`) - ├─ localStorage.setItem() - └─ JSON.stringify()