Skip to content

fix(broadcast): restart event sampling for send-only channels - #2466

Merged
edgurgel merged 2 commits into
supabase:mainfrom
hsusul:fix/broadcast-sender-idle-counter
Nov 3, 2026
Merged

edgurgel merged 2 commits into
supabase:mainfrom
hsusul:fix/broadcast-sender-idle-counter

Conversation

@hsusul

@hsusul hsusul commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

A send-only WebSocket channel (self: false, no other listeners) keeps acknowledging Broadcast messages after its events sampler stops for idleness, but never restarts sampling. The handler increments the raw counter while only receiving channels request sampler recovery.

Ensure the sampler exists before incrementing the accepted send. Restart arguments come from the current tenant cache, preserving updated limits. Initialization must precede the increment because it resets the raw counter. The existing one-second shutdown cache grace is unchanged; recovery is covered after that entry expires. This restores sampling and telemetry without adding sender-side rate enforcement.

Regression tests use actual acknowledged channel sends after normal idle shutdown and verify all three events reach the sampled bucket. The existing raised-limit test now restarts through real sends and verifies the current limit and all 100 sampled events.

Validated on upstream f5f0dab9:

  • Both focused tests fail upstream for the missing sampler and pass fixed. Independently repeated with production-only reversion.
  • Standalone issue reproduction fails upstream and passes fixed.
  • BroadcastHandler, RealtimeChannel, RateCounter and MessageDispatcher suites pass 287 tests.
  • Formatter, force compilation and test compilation with warnings as errors, strict Credo, unused dependencies, configured Sobelow, Dialyzer and git diff --check pass. Dialyzer retains 13 configured ignores and zero unnecessary skips.

Local validation uses Elixir 1.19.5, OTP 28.5.0.8 and native PostgreSQL 17.11 with repository auth fixtures. CI pins OTP 28.5.0.4. Docker integration/E2E and hosted CI are not established by these local checks.

Closes #2465.

@edgurgel
edgurgel merged commit 67d336c into supabase:main Nov 3, 2026
47 checks passed
@realtime-release-bot

Copy link
Copy Markdown

🎉 This PR is included in version 2.151.7 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Send-only broadcasts do not restart event sampling after idle shutdown

2 participants