mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-07-03 12:02:30 +02:00
ensure subscription dies if the relay connection dies.
This commit is contained in:
6
relay.go
6
relay.go
@ -402,6 +402,12 @@ func (r *Relay) PrepareSubscription(ctx context.Context) *Subscription {
|
||||
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
|
||||
go func() {
|
||||
// ensure the subscription dies if the relay connection dies
|
||||
<-r.connectionContext.Done()
|
||||
cancel()
|
||||
}()
|
||||
|
||||
return &Subscription{
|
||||
Relay: r,
|
||||
Context: ctx,
|
||||
|
Reference in New Issue
Block a user