Skip to content

fix: prevent duplicate zap counting from race conditions#84

Merged
barrydeen merged 1 commit intomainfrom
fix/zap-dedup-race
Feb 28, 2026
Merged

fix: prevent duplicate zap counting from race conditions#84
barrydeen merged 1 commit intomainfrom
fix/zap-dedup-race

Conversation

@barrydeen
Copy link
Copy Markdown
Owner

Summary

  • EventRepository: Wrap countedZapIds get-or-create in a synchronized block to prevent concurrent collectors (e.g. thread-reactions + notif) from creating separate dedup sets for the same target, causing zaps to be double-counted
  • NotificationRepository: Add secondary event ID tracking in mergeZap to guard against LRU eviction in seenEvents allowing the same 9735 event to be re-processed on periodic refresh cycles — unlike mergeReaction which already has inner pubkey dedup, mergeZap was blindly appending

Test plan

  • Send a zap and verify the count increments by 1, not 2+
  • Check notifications after a few minutes of usage — zap entries should not duplicate
  • View a thread containing a zapped post while notifications are active — no double counting

EventRepository: wrap countedZapIds get-or-create in synchronized block
to prevent concurrent threads (e.g. thread-reactions + notif collectors)
from creating separate dedup sets for the same target event.

NotificationRepository: add secondary event ID dedup in mergeZap to
guard against LRU eviction in seenEvents allowing the same 9735 event
to be re-processed on periodic refresh cycles.
@barrydeen barrydeen merged commit d716244 into main Feb 28, 2026
@barrydeen barrydeen deleted the fix/zap-dedup-race branch March 4, 2026 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant