From 6ad42bde29c354b3c006751429ab816a590cea44 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Mon, 22 Sep 2025 22:52:58 +0300 Subject: [PATCH] added DefaultClient.Send panic/recover handling as an extra precaution --- tools/subscriptions/client.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/subscriptions/client.go b/tools/subscriptions/client.go index fa0d513f..b9ba89fc 100644 --- a/tools/subscriptions/client.go +++ b/tools/subscriptions/client.go @@ -272,12 +272,14 @@ func (c *DefaultClient) IsDiscarded() bool { // Send sends the specified message to the client's channel (if not discarded). func (c *DefaultClient) Send(m Message) { - c.mu.RLock() - defer c.mu.RUnlock() - - if c.isDiscarded { + if c.IsDiscarded() { return } + // gracefully handle panics since channel close is not blocking and could cause races + defer func() { + recover() + }() + c.channel <- m }