From 0630bbe4e9e3f2108a1a8c745b5a98339270176c Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Fri, 20 Mar 2026 20:26:59 -0300 Subject: [PATCH] fix another dead relay issue (relays dying but subscriptions living forever and not being reconnected). --- relay.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/relay.go b/relay.go index c1ccd19..9108a0e 100644 --- a/relay.go +++ b/relay.go @@ -620,6 +620,16 @@ func (r *Relay) PrepareSubscription(ctx context.Context, filter Filter, opts Sub }() } + // if the relay connection dies, cancel this subscription + go func() { + select { + case <-sub.Context.Done(): + return + case <-r.connectionContext.Done(): + sub.cancel(context.Cause(r.connectionContext)) + } + }() + // start handling events, eose, unsub etc: go func() { <-sub.Context.Done()