we-promise/sure · warning

<%= class_name %>ActivitiesFetchJob - Broadcast failed: #{e.

Error message

<%= class_name %>ActivitiesFetchJob - Broadcast failed: #{e.message}

What it means

Generated by the provider generator, this job finishes an activities fetch and then calls broadcast_updates to push Turbo Stream updates: broadcast_sync_complete on the linked account and broadcast_replace_to re-rendering the provider item partial. Any StandardError raised in that UI broadcast path is rescued and downgraded to a warning, so the sync result itself (already persisted) is unaffected — only the live page refresh is lost. Users must reload manually.

Source

Thrown at lib/generators/provider/family/templates/activities_fetch_job.rb.tt:126

        @<%= file_name %>_account,
        start_date: @start_date,
        retry_count: @retry_count + 1
      )
    end

    def clear_pending_flag
      @<%= file_name %>_account.update!(activities_fetch_pending: false)
    end

    def broadcast_updates
      @<%= file_name %>_account.current_account&.broadcast_sync_complete
      @<%= file_name %>_account.<%= file_name %>_item&.broadcast_replace_to(
        @<%= file_name %>_account.<%= file_name %>_item.family,
        target: "<%= file_name %>_item_#{@<%= file_name %>_account.<%= file_name %>_item.id}",
        partial: "<%= file_name %>_items/<%= file_name %>_item"
      )
    rescue => e
      Rails.logger.warn("<%= class_name %>ActivitiesFetchJob - Broadcast failed: #{e.message}")
    end
end

View on GitHub (pinned to e69894adb9)

Solutions

  1. Read the e.message half of the log line — nil errors point at unlinked records, missing-template errors point at the partial path
  2. Guard the broadcast: return early unless current_account and <%= file_name %>_item are present before broadcasting
  3. Verify the partial app/views/<%= file_name %>_items/_<%= file_name %>_item.html.erb exists after any renaming, both in the generated app and the .tt template
  4. If ActionCable is the cause, check the cable adapter/Redis configuration

Example fix

# generated job - before
def broadcast_updates
  @account.current_account&.broadcast_sync_complete
  @account.item&.broadcast_replace_to(...)
end

# generated job - after
def broadcast_updates
  item = @account.<%= file_name %>_item
  return unless @account.current_account && item

  @account.current_account.broadcast_sync_complete
  item.broadcast_replace_to(item.family, target: "<%= file_name %>_item_#{item.id}", partial: "<%= file_name %>_items/<%= file_name %>_item")
end
Defensive patterns

Strategy: validation

Validate before calling

# Only broadcast when the records and partial still exist (generated job)
def broadcast_updates
  item = @account.<%= file_name %>_item
  linked = @account.current_account
  partial = "<%= file_name %>_items/<%= file_name %>_item"
  return unless linked && item && lookup_context.exists?(partial, [], true)

  linked.broadcast_sync_complete
  item.broadcast_replace_to(item.family, target: "<%= file_name %>_item_#{item.id}", partial: partial)
end

Try / catch

# Keep the broad rescue but log with enough context to act
rescue => e
  Rails.logger.warn("<%= class_name %>ActivitiesFetchJob - Broadcast failed: #{e.class} #{e.message} account=#{@account&.id} item=#{@account&.<%= file_name %>_item&.id}")
end

Prevention

When it happens

Trigger: current_account (account_provider link) is nil because the provider account was unlinked or the account deleted mid-job; <%= file_name %>_item is nil (item destroyed while the job ran); the target partial path "<%= file_name %>_items/<%= file_name %>_item" does not exist because the generator output was renamed; ActionCable/Turbo configuration raising during publish.

Common situations: User unlinks an account while a background sync is in flight; developer renames generated files/partial directories after generation; cable adapter misconfigured (e.g. Redis unavailable for ActionCable); staging environments without WebSockets.

Related errors


AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21). Data as JSON: /api/errors/c0c34d6c52bf43d1. Report an issue: GitHub.