mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-07-03 20:17:04 +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)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
// ensure the subscription dies if the relay connection dies
|
||||||
|
<-r.connectionContext.Done()
|
||||||
|
cancel()
|
||||||
|
}()
|
||||||
|
|
||||||
return &Subscription{
|
return &Subscription{
|
||||||
Relay: r,
|
Relay: r,
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
|
Reference in New Issue
Block a user