fix(cache): make the failed-publish restore survive the from-cache filter (#64) #71
No reviewers
Labels
No labels
bug
discussion
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
edufeed/edufeed-app!71
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/issue-64-restore-from-cache"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to #69. Found by TestOER against merged
dev(59b2de15).The restore from #69 reaches memory but not IndexedDB whenever the predecessor came from the cache — which is every path with a page reload in it (open app, open resource, edit). So the 404 it was meant to prevent is still there on
dev.Cause — one line of applesauce
An event loaded through
cacheRequestcarriesSymbol.for('from-cache').publishEventOptimisticre-adds that same object, sopersistEventsToCacheskips it:eventStore.addrestores the UI and the durable write silently never happens.The marker's premise — it is already in the cache, no need to write it back — was true when it was set and is false by the time we restore, because
uncacheEventhas just deleted that row.TestOER's measurement:
insert$fires in both cases ([GOOD, PHANTOM, GOOD]) and memory endsGOODin both — the write is dropped one layer down.Fix — direct write, not marker-clearing
recacheEventputs the predecessor straight into IDB, after the un-cache and alongside the existingeventStore.add.Chosen over stripping the symbol because it does not depend on an applesauce internal keeping its current shape — and because
{...previous}does NOT strip it: object spread copies own enumerable symbol properties. There is a test asserting exactly that, so the tempting one-liner cannot be reintroduced by accident.recacheEventhonoursCACHEABLE_KINDS, which theinsert$writer applies too — a direct write must not smuggle in a kind we deliberately do not persist.Verification
Load-bearing checks confirmed by reverting what they cover:
The from-cache drop is also pinned directly against the real pipeline: an event carrying the marker is proved not to reach IDB through
insert$, with a keeper event in the same batch so the absence cannot pass vacuously.Not established
Not re-measured in a browser. TestOER's reload scenario at
59b2de15is what found this, and the same scenario is what should confirm it.