admin管理员组文章数量:1126324
Something very strange is happening to me.
From my controller I do:
CreateMassBalanceJob.set(wait: 1.seconds).perform_later(
excel_file_path: path_to_tmp_file,
mass_balance_id: @mass_balance.id
CreateMassBalanceJob runs this method:
def stream_notification_message(message, type: 'success')
notification_stream = notification_message_helper_stream(message,
to_string: true,
type:)
puts 'ENTRA EN stream_notification_message'
Turbo::StreamsChannel.broadcast_prepend_to(
'global_notifications',
target: 'notifications_',
html: notification_stream
)
puts 'SALE EN stream_notification_message'
end
In it I write the Input and Output for issues of debug what is happening.
I do a Turbo::StreamsChannel.broadcast_prepend_to through the global_notifications channel to send a notification to the user's view.
But sometimes it happens that, even though the debug output clearly shows me that the method is executed only once, and that broadcast_prepend_to is executed only once, the Backend sends the action 3 times (sometimes more. It's random).
It is also observed in the Web browser on the client side:
In the application.html.erb layout I have:
<%= turbo_stream_from :global_notifications %>
And obviously, it is showing me the same notification message several times:
I don't know what else to check. Has this happened to anyone else?
I am using:
- OS: Windows 11
- ruby 3.2.6
- Rails 8.0.1
本文标签: ruby on railsTurboStreamsChannel sends the same action multiple timesStack Overflow
版权声明:本文标题:ruby on rails - Turbo::StreamsChannel sends the same action multiple times - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736683665a1947552.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论