Testing story: app-level broadcast audits (global ActionCable.server) can be silently buffered by ActionCable::TestHelper, and 4.1.x gives tests no synchronous flush
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 30/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 領域
- documentation, testing
調査の方向性
Start with the README testing section and the inline_broadcasts mode in solid_cable_test.rb, then trace how ActionCable::TestHelper swaps the pubsub adapter to SubscriptionAdapter::Test on the global ActionCable.server. The documentation note should explain the swap and how to reset it or use a dedicated server. The optional flush_broadcasts helper for BatchedBroadcaster needs maintainer agreement on direction before any code is written.
索引モデルが issue の本文から書いたものです。
説明
(Cross-reference: we filed hotwired/turbo-rails#793 about the
auto-inclusion mechanism; this one is the Solid Cable side of the same
finding: what it means for Solid Cable users and what could be added.)
Context
A Rails 8 app auditing Solid Cable's core promise in a test ("a broadcast
is a DB INSERT into solid_cable_messages") wrote this test:
test "broadcast lands in solid_cable_messages as a DB row" do
ActionCable.server.broadcast("solid_cable_audit", payload)
row = poll_until { SolidCable::Message.order(:created_at).last } # up to 30s
assert_not_nil row
end
and watched it fail intermittently, with the row never appearing at all,
while the same test passed standalone and in other suite orderings.
Root cause (full instrumented timeline in hotwired/turbo-rails#793):
turbo-rails auto-includes Turbo::Broadcastable::TestHelper (which pulls
in ActionCable::TestHelper) into every ActiveSupport::TestCase
mid-suite. ActionCable::TestHelper#before_setup then swaps the global
ActionCable.server's pubsub to the buffered SubscriptionAdapter::Test
adapter for every test. Solid Cable is never consulted, no row is ever
written, and nothing logs or raises.
Why Solid Cable's own suite doesn't see this
Your adapter tests construct their own
ActionCable::Server::Base.new per test with their own cable config, so
the global-server hijack can't touch them, but it bites every application
test that uses ActionCable.server directly, which is the natural way an
app verifies "broadcast → DB row". Since Solid Cable is the Rails default
pubsub, this interaction is likely to keep surprising users.
The async-writer side
Even with the real adapter active, BatchedBroadcaster (4.1.x) gives tests
no synchronous flush: we observed the writer thread's first flush lagging
past 10s once on a cold process (both runtimes), which forced a 30s poll
budget. Your own suite engineers around exactly this with a poll helper
(wait_for_messages, sleep 0.001 until ... under a 5s Timeout).
Main's inline_broadcasts mode (writes synchronously inside the Rails
executor, verified against your solid_cable_test.rb) is a big
improvement, but note it does not fix the buffering problem above:
ActionCable::SubscriptionAdapter::Test never reaches SolidCable at all,
so no Solid Cable-side mode can help while the swap is active.
What we'd like
- Documentation (README testing section): when testing broadcasts
against the DB through the globalActionCable.server, beware
ActionCable::TestHelperswapping the pubsub (auto-included by
turbo-rails); reset the adapter (ActionCable.server .instance_variable_set(:@pubsub, nil)) or construct a dedicated server.
This note is the part that helps users today:inline_broadcasts
(see above) does not cover the swap, because a broadcast that is
buffered by the Test adapter never reaches SolidCable. - Optionally a small
SolidCable::Testinghelper (e.g. a
flush_broadcaststhat drains the currentBatchedBroadcasterqueue,
or guidance to enableinline_broadcastsin the test environment)
so app-level audit tests don't need hand-rolled 30s polls.
Both are small; happy to send PRs for either once the direction is OK'd.
- 主要言語
- Ruby
- スター
- 348
- フォーク
- 33
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rails/solid_cable のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
rails/solid_cable#97 · コメント 1 件 ·
rails/solid_cable の issue をすべて見る
似ている issue
-
Bug Ruby Waiting for: Product Owner
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
getsentry/sentry-ruby#3228 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
開発用DockerイメージにPlaywrightのシステム依存を追加する対応中かも @momocus が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
sakazuki-org/sakazuki#1453 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
jenkins-infra/jenkins.io#9615 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信