From 5c3ffeacb37429233c7eae5602e013e0f84d40c2 Mon Sep 17 00:00:00 2001 From: Mag A Date: Wed, 31 Jan 2024 13:05:39 -0800 Subject: [PATCH] fix: prevent ConsumerGroup.Close infinitely locking (#2717) Signed-off-by: Magomed Abdurakhmanov --- consumer_group.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/consumer_group.go b/consumer_group.go index 05030efbc..53b64dd3b 100644 --- a/consumer_group.go +++ b/consumer_group.go @@ -213,8 +213,11 @@ func (c *consumerGroup) Consume(ctx context.Context, topics []string, handler Co return err } - // Wait for session exit signal - <-sess.ctx.Done() + // Wait for session exit signal or Close() call + select { + case <-c.closed: + case <-sess.ctx.Done(): + } // Gracefully release session claims return sess.release(true)