Skip to content

Commit

Permalink
Prevent sporadic hangs with Solid Cable
Browse files Browse the repository at this point in the history
I can simulate hangs in the server by opening many tabs and, in parallel, perform many
modifications to a monitored file very quickly. This seems to fix those for good.
  • Loading branch information
jorgemanrubia committed Dec 21, 2024
1 parent 13a3cdf commit 24693c2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/hotwire/spark/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ def monitor(paths_name, action:)
end

def broadcast_reload_action(action, file_path)
Hotwire::Spark.cable_server.broadcast "hotwire_spark", reload_message_for(action, file_path)
broadcast_mutex.synchronize do
Hotwire::Spark.cable_server.broadcast "hotwire_spark", reload_message_for(action, file_path)
end
end

def broadcast_mutex
@broadcast_mutex ||= Mutex.new
end

def reload_message_for(action, file_path)
Expand Down

0 comments on commit 24693c2

Please sign in to comment.