From 6b6197f4f10688084f73636c105096e091bc07f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20B=C3=BChler?= Date: Thu, 4 Mar 2021 08:45:18 +0100 Subject: [PATCH] fix unsubscribeFromAllChannels / stale connections the `each->` call silently ran only for the first channel leading to users on other channels seeming randomly not getting unsubscribed, stale connections, a frustrated dev and a fishy smell all over the place. after some serious hours of debugging and searching for this sneaky bug the websocket-world is now a better place ;) --- src/ChannelManagers/LocalChannelManager.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ChannelManagers/LocalChannelManager.php b/src/ChannelManagers/LocalChannelManager.php index 46e3615131..fd824bc169 100644 --- a/src/ChannelManagers/LocalChannelManager.php +++ b/src/ChannelManagers/LocalChannelManager.php @@ -173,7 +173,10 @@ public function unsubscribeFromAllChannels(ConnectionInterface $connection): Pro $this->getLocalChannels($connection->app->id) ->then(function ($channels) use ($connection) { - collect($channels)->each->unsubscribe($connection); + collect($channels) + ->each(function (Channel $channel) use ($connection) { + $channel->unsubscribe($connection); + }); collect($channels) ->reject->hasConnections()