Skip to content

Commit e5bfdf8

Browse files
committed
Fix Action Cable compatibility with redis-rb 5.4.1
Fix: rails#55355 Action Cable was depending on a bug of redis-rb, but the bug has now been fixed.
1 parent e5e1ce7 commit e5bfdf8

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,9 @@ GEM
473473
rdoc (6.9.1)
474474
psych (>= 4.0.0)
475475
redcarpet (3.6.1)
476-
redis (5.3.0)
476+
redis (5.4.1)
477477
redis-client (>= 0.22.0)
478-
redis-client (0.24.0)
478+
redis-client (0.25.1)
479479
connection_pool
480480
redis-namespace (1.11.0)
481481
redis (>= 4)

actioncable/lib/action_cable/subscription_adapter/redis.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def ensure_listener_running
164164
begin
165165
conn = @adapter.redis_connection_for_subscriptions
166166
listen conn
167-
rescue ConnectionError
167+
rescue *CONNECTION_ERRORS
168168
reset
169169
if retry_connecting?
170170
when_connected { resubscribe }
@@ -210,7 +210,7 @@ def reset
210210
end
211211

212212
if ::Redis::VERSION < "5"
213-
ConnectionError = ::Redis::BaseConnectionError
213+
CONNECTION_ERRORS = [::Redis::BaseConnectionError].freeze
214214

215215
class SubscribedClient
216216
def initialize(raw_client)
@@ -244,7 +244,12 @@ def extract_subscribed_client(conn)
244244
SubscribedClient.new(conn._client)
245245
end
246246
else
247-
ConnectionError = RedisClient::ConnectionError
247+
CONNECTION_ERRORS = [
248+
::Redis::BaseConnectionError,
249+
250+
# Some older versions of redis-rb sometime leak underlying exceptions
251+
RedisClient::ConnectionError,
252+
].freeze
248253

249254
def extract_subscribed_client(conn)
250255
conn

0 commit comments

Comments
 (0)