From a5ecb7975e3af4260ca7923e1c4d8b868bec59e2 Mon Sep 17 00:00:00 2001 From: WarmUpTill <19472752+WarmUpTill@users.noreply.github.com> Date: Wed, 29 Apr 2026 14:18:05 +0200 Subject: [PATCH] Fix potential event sub freeze on disconnect --- plugins/twitch/event-sub.cpp | 10 ++++------ plugins/twitch/token.cpp | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/twitch/event-sub.cpp b/plugins/twitch/event-sub.cpp index 9bd308b3..a4a37f8c 100644 --- a/plugins/twitch/event-sub.cpp +++ b/plugins/twitch/event-sub.cpp @@ -83,6 +83,10 @@ void EventSub::ConnectThread() } else { _client->connect(con); _connection = connection_hdl(con); + if (_disconnect) { + _client->close(con, websocketpp::close::status::normal, + "Twitch EventSub stopping", ec); + } _client->run(); } @@ -157,12 +161,6 @@ void EventSub::Disconnect() _cv.notify_all(); } - while (_connected) { - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - _client->close(_connection, websocketpp::close::status::normal, - "Twitch EventSub stopping", ec); - } - if (_thread.joinable()) { _thread.join(); } diff --git a/plugins/twitch/token.cpp b/plugins/twitch/token.cpp index aac39a9c..f62a4004 100644 --- a/plugins/twitch/token.cpp +++ b/plugins/twitch/token.cpp @@ -87,6 +87,7 @@ static bool setupTwitchTokenSupport() { AddSaveStep(saveConnections); AddLoadStep(loadConnections); + AddPluginCleanupStep([]() { twitchTokens.clear(); }); return true; }