From 39dee8abc576cbf833d95b49c9de17d8c0bde288 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Mon, 23 Aug 2021 16:41:45 -0400 Subject: [PATCH] pubsub: improve handling of closed blocking subsciptions. (#6852) --- libs/pubsub/pubsub.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/pubsub/pubsub.go b/libs/pubsub/pubsub.go index 7548470b5..68d1ec941 100644 --- a/libs/pubsub/pubsub.go +++ b/libs/pubsub/pubsub.go @@ -507,7 +507,10 @@ func (state *state) send(msg interface{}, events []types.Event) error { for clientID, subscription := range clientSubscriptions { if cap(subscription.out) == 0 { // block on unbuffered channel - subscription.out <- NewMessage(subscription.id, msg, events) + select { + case subscription.out <- NewMessage(subscription.id, msg, events): + case <-subscription.canceled: + } } else { // don't block on buffered channels select {