forked from coracle/nostrlib
fix another dead relay issue (relays dying but subscriptions living forever and not being reconnected).
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user