-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
When the gift wrap subscription (fetchGiftWrapsForPublicKey) drops and reconnects, any NIP-17 gift wraps published during the reconnect window are permanently missed. There is no backfill mechanism to catch up on events received while the subscription was down.
Root Cause
In app/utils/nostr.ts, the subscription reconnect logic re-establishes the connection but starts listening from now with no since filter:
onclose: () => {
closer.close()
closer = fetchGiftWrapsForPublicKey(pubkey, eventHandler, pool)
},The new subscription call has no since timestamp, so any events published during the gap between close and reconnect are never fetched.
Impact
- Messages sent while the recipient's subscription is reconnecting are silently dropped
- Manifests as "Missed a note" / "Missed N notes" in the chat UI
- Intermittent — depends on relay connection stability and timing
- Observed during QA testing of PR QOL features on chat #579
Suggested Fix
Track the last event timestamp received (lastSeenAt) and pass it as a since filter on reconnect:
let lastSeenAt = Math.floor(Date.now() / 1000)
onclose: () => {
closer.close()
closer = fetchGiftWrapsForPublicKey(pubkey, eventHandler, pool, lastSeenAt)
},
// In the subscription:
onevent: (event) => {
lastSeenAt = Math.max(lastSeenAt, event.created_at)
eventHandler(event)
}This ensures reconnects backfill any events missed during the gap.
Steps to Reproduce
- Open two accounts in chat (iOS simulator + Android emulator)
- Send messages back and forth rapidly
- Observe "Missed a note" appearing on one side
- Check Metro logs — subscription reconnect events coincide with missed messages
References
- PR QOL features on chat #579 (where this was observed during QA)
- NIP-17 gift wrap spec
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working