fix(events): publish bookmarks with monotonic created_at (#122) #126
No reviewers
Labels
No labels
app:activities
app:chat
app:events
app:forum
app:libra
app:market
app:restaurant
app:tasks
app:wallet
app:webapp
bug
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
aiolabs/webapp!126
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/monotonic-created-at"
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 the gap from the nostr-patterns review — and the same root cause found while debugging the live ticket count. Fixes #122.
Problem
Relays only push a replaceable-event update to open subscriptions when its
created_atis strictly newer than the held version.created_atis second-resolution, souseBookmarks'Math.floor(Date.now()/1000)lets two rapid toggles collide in the same second — the second is treated as not-newer and never reaches live subscribers (only a reload surfaces it).Fix
monotonicCreatedAt(lastCreatedAt, now?)=max(now, last+1)insrc/lib/nostr/timestamp.ts— reusable for any replaceable-event publisher.toggleBookmark; tracklastCreatedAtas a typed field onBookmarkState(drops the(state as any)casts).Tests
src/lib/nostr/timestamp.spec.ts: no-prior, same-second bump, wall-clock tracking, future-dated prior (clock skew), and a strictly-increasing same-second burst. Run withpnpm test.Follow-up (not in this PR)
The
aiolabs/eventsextension'snostr_publisherusesint(time.time())the same way — flagged in #122 for a backend follow-up.Merge order
Branches off
chore/vitest-setup(the vitest PR) — merge that first; this PR's diff drops the vitest files once it lands.🤖 Generated with Claude Code