diff --git a/relay.go b/relay.go index 39f8e17..59d2cf2 100644 --- a/relay.go +++ b/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,