4

I'm running a rails 6 app that is heavily using all sorts of hotwire goodness. I noticed that after a deploy my turbo streams stopped working.

In my view I've got

<%= turbo_stream_from "#{dom_id(@class)}_lesson" %>

Which in theory should start listening on an ActionCable channel, however, that is not happening. I can't see any message in my console that confirms that the action cable channel is connected and therefore any turbo broadcast I do is not being received by my frontend

broadcast_update_to "school_class_#{id}_lesson", target: "question_#{question.id}_lock",
        partial: "lessons/lock_overlay"

The broadcast tries to do what its told as I can see from my server logs

[ActionCable] Broadcasting to school_class_15_lesson: "<turbo-stream action=\"update\" target=\"question_58_lock\"><template></template></turbo-stream>"

However, since the stream is not active the frontend is not receiving the update.

There's only one thing that may have broken this in the latest code changes. I wired sidekiq to handle my background jobs. This means that I added a new redis.rb initializer

$redis = Redis.new

url = ENV["REDISCLOUD_URL"]

if url
  Sidekiq.configure_server do |config|
    config.redis = { url: url }
  end

  Sidekiq.configure_client do |config|
    config.redis = { url: url }
  end
  $redis = Redis.new(:url => url)
end

Which doesn't look like it would break anything. To add some context, this is my cable.yml file

development:
  adapter: redis
  url: redis://localhost:6379/1

test:
  adapter: test

staging:
  adapter: redis
  url: <%= ENV.fetch("REDISCLOUD_URL") { "redis://localhost:6379/1" } %>
  channel_prefix: cable_staging
  ssl_params: {
    verify_mode: <%= OpenSSL::SSL::VERIFY_NONE %>
  }

production:
  adapter: redis
  url: <%= ENV.fetch("REDISCLOUD_URL") { "redis://localhost:6379/1" } %>
  channel_prefix: cable_production
  ssl_params: {
    verify_mode: <%= OpenSSL::SSL::VERIFY_NONE %>
  }

Can you think of anything that may have broken the existing setup that had been working for over a year?

ilrock
  • 573
  • 8
  • 24

0 Answers0