Queue outgoing events when relay connection is down #1

Open
opened 2026-04-27 17:33:45 +00:00 by padreug · 0 comments
Owner

Problem

When the relay connection is temporarily lost, nostrclient drops any events published during the disconnection window. Extensions (nostrmarket, events) publish via nostrclient's internal WebSocket, which queues the ["EVENT", ...] message — but nostrclient's relay connection may be down at that moment, and the event is silently lost.

Observed: events extension published a NIP-52 calendar event at 17:21:58, but the nostrclient relay connection was lost at 17:18:43 and didn't reconnect until 17:22:53. The event never reached the relay.

Expected behavior

Outgoing EVENT messages should be queued and retried when the relay reconnects, not dropped.

Proposed solution

  • Add a bounded outgoing event queue (e.g., 100 events max)
  • When relay.send() fails or relay is disconnected, queue the event
  • On reconnection, flush the queue before accepting new events
  • Drop oldest events if queue is full (bounded to prevent memory issues)

Impact

This affects all extensions that publish via nostrclient:

  • nostrmarket (stall/product/DM publishing)
  • events (NIP-52 calendar event publishing)

Workaround

Currently, extensions can re-publish events manually (e.g., re-approve an event). But this isn't automatic.

## Problem When the relay connection is temporarily lost, nostrclient drops any events published during the disconnection window. Extensions (nostrmarket, events) publish via nostrclient's internal WebSocket, which queues the `["EVENT", ...]` message — but nostrclient's relay connection may be down at that moment, and the event is silently lost. Observed: events extension published a NIP-52 calendar event at 17:21:58, but the nostrclient relay connection was lost at 17:18:43 and didn't reconnect until 17:22:53. The event never reached the relay. ## Expected behavior Outgoing EVENT messages should be queued and retried when the relay reconnects, not dropped. ## Proposed solution - Add a bounded outgoing event queue (e.g., 100 events max) - When `relay.send()` fails or relay is disconnected, queue the event - On reconnection, flush the queue before accepting new events - Drop oldest events if queue is full (bounded to prevent memory issues) ## Impact This affects all extensions that publish via nostrclient: - nostrmarket (stall/product/DM publishing) - events (NIP-52 calendar event publishing) ## Workaround Currently, extensions can re-publish events manually (e.g., re-approve an event). But this isn't automatic.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aiolabs/nostrclient#1
No description provided.