release a goroutine that could leak in some conditions.

This commit is contained in:
fiatjaf
2025-09-07 18:56:26 -03:00
parent 9933bb7865
commit b67e3092b0

View File

@@ -364,8 +364,11 @@ func (r *Relay) Subscribe(ctx context.Context, filter Filter, opts SubscriptionO
}
go func() {
<-r.connection.closedNotify
sub.unsub(ErrDisconnected)
select {
case <-r.connection.closedNotify:
sub.unsub(ErrDisconnected)
case <-ctx.Done():
}
}()
return sub, nil