fix(cache): offer published events to the EventStore, and stop caching phantoms (#64) #69
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!69
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/issue-64-eventstore-add-omissions"
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?
Closes #64.
Four sibling sites of #62, a shared helper, and — after TestOER's browser measurement — a restore of the version a failed publish replaced.
Why any of this matters
The IndexedDB cache is the first step of applesauce's
addressPointerLoadingSequence, and a cache hit ends it. So for a cacheable kind, whatever is in IDB is what the app shows, and a relay cannot correct it. The cache is fed only fromeventStore.insert$, andpublishEventnever touches the EventStore.Sites fixed
relay-settings-service.jseventStorereferences. The relay list itself, so a stale read mis-routes every subsequent querycalendar-actionscreateCalendarpublishEventOptimisticfailure pathcalendarActions.deleteEventeventStore.addnorcacheDeletion. RemovedThe failed-publish path, as measured rather than as I first described it
TestOER ran the discriminating experiment in a real browser — unmocked pipeline, IndexedDB read directly, bogus-address control, four dead-relay modes. Two of my original claims did not survive it, and both are corrected here:
1.
uncacheEventalone deletes, it does not recover. The phantom overwrites the good version at its address before anything knows the publish failed, so deleting it leaves the address EMPTY — 9/9 trials. User-visibly that is a 404 on a resource that exists. SopublishEventOptimisticnow captures the replaced version before the optimistic add — the only moment it is still reachable — and re-adds it after the un-cache. Ordering is load-bearing: nostr-idb only writes a replaceable event when it is newer than the entry at its address, so restoring first is silently rejected.2. The
hasEventflush-time guard does not fire on this path. The fastest possible failure reports at 1006-1015ms (5/5) becausegetPublishRelaysdoes a relay-list lookup before publishing starts, while the batch flushes at 1000ms. Deleting the guard left outcomes identical 5/5. It is not a co-equal second guard for #64; it is kept for the invariant it does cover — superseded replaceable versions, NIP-09 deletions — and the comment and test name now say so.uncacheEventis the whole of the #64 fix: disabled, the phantom leaks 4/4.Shared helper
nextCreatedAt()+cachePublishedEvent()inhelpers/replaceableUpdates.js. AdoptingnextCreatedAtsurfaced three further update paths carrying the #62 bug with no guard —updateWiki(30818),updateArticle(30023),updateResource(30142). On a same-second tie nostr-idb keeps the OLD version deterministically. TestOER confirmedupdateResourcein a browser:created_at1785441994 -> 1785441995, d-tag preserved.Verification
The 6 failures are five DM/inbox/gift-wrap files that fail identically on unmodified
devunder the same load. I randev's full suite twice: once fully clean, once with the same five red. Load-dependent 5s/30s timeouts, same family as the knownGlobalFABflake — pre-existing, not this branch. Worth its own issue.Every new assertion confirmed load-bearing by reverting the code it covers:
Known limits
nextCreatedAtinrelay-settings-serviceresolves the previous list from the EventStore; if it was never loaded there the guard falls back to wall-clock time. No worse than theDate.now()it replaces.13ac018d, before it existed.