From 8b3d3bdc9801a3b298941d7bcdaace72ced3dc81 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sat, 16 Dec 2023 12:52:54 +0100 Subject: [PATCH] [eventsub] Fix: Stop subscription-retries when client is closed Signed-off-by: Knut Ahlers --- pkg/twitch/eventsubWebsocketClient.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/twitch/eventsubWebsocketClient.go b/pkg/twitch/eventsubWebsocketClient.go index a922463..12103ea 100644 --- a/pkg/twitch/eventsubWebsocketClient.go +++ b/pkg/twitch/eventsubWebsocketClient.go @@ -421,6 +421,12 @@ func (e *EventSubSocketClient) retryBackgroundSubscribe(st eventSubSocketSubscri WithMaxTotalTime(retrySubscribeMaxTotal). WithMinIterationTime(retrySubscribeMinWait). Retry(func() error { + if err := e.runCtx.Err(); err != nil { + // Our run-context was cancelled, stop retrying to subscribe + // to topics as this client was closed + return backoff.NewErrCannotRetry(err) + } + return e.subscribe(st) }) if err != nil {