Skip to content

Commit

Permalink
Correctly release connections in cable apps
Browse files Browse the repository at this point in the history
  • Loading branch information
rsamoilov committed Sep 11, 2024
1 parent bc2fb2e commit 143499f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/rage/cable/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __register_action_proc(action_name)
end

is_subscribing = action_name == :subscribed
activerecord_loaded = defined?(::ActiveRecord)
should_release_connections = Rage.config.internal.should_manually_release_ar_connections?

method_name = class_eval <<~RUBY, __FILE__, __LINE__ + 1
def __run_#{action_name}(data)
Expand Down Expand Up @@ -163,13 +163,10 @@ def __run_#{action_name}(data)
#{periodic_timers_chunk}
#{rescue_handlers_chunk}
#{if activerecord_loaded
#{if should_release_connections
<<~RUBY
ensure
# TODO
if ActiveRecord::Base.connection_pool.active_connection?
ActiveRecord::Base.connection_handler.clear_active_connections!
end
ActiveRecord::Base.connection_handler.clear_active_connections!(:all)
RUBY
end}
end
Expand Down

0 comments on commit 143499f

Please sign in to comment.