除非重新加载页面,否则 ActionCable 通道不会连接

ActionCable channel doesn't connect unless page is reloaded

如果我手动刷新页面,我有一根电缆效果很好,但如果我导航到它,它永远不会开始流式传输。

当正常工作时,我在 Rails 控制台中看到:

ChecklistPdfChannel is transmitting the subscription confirmation
ChecklistPdfChannel is streaming from checklist_pdf_2-5a-ntiasohen-gattopuin

这是咖啡脚本:

document.addEventListener 'turbolinks:load', ->
  if !App.presence
    App.presence = App.cable.subscriptions.create({
      channel: 'ChecklistPdfChannel',
      issueable_id: window.location.pathname.split('/').splice(2,1).toString()
    },
      connected: ->
      disconnected: ->
      received: (data) ->
        console.log(data)
        $('#pdf_status').html "#{data.html}"
  )
return

我试过以下方法:

开发和 staging/production (Heroku) 中的行为相同。

Rails 5.2.2,ActionCable 5.2.2,Turbolinks 5.2.0

所以我能够让它工作的唯一方法是在我需要激活电缆的页面上添加这个元标记:

<meta name="turbolinks-visit-control" content="reload">