Fix: Store broadcast channels on BroadcastManager to ensure coroutine-safe authorization #286
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When using pooled broadcast drivers (Pusher, Ably), channel authorization fails with 403 errors because channels registered via
Broadcast::channel()are proxied through__call()to individual pooled driver instances.In a coroutine environment:
Broadcast::channel('App.Models.User.{id}', ...)is called at boot time → registers on pooled instance ABroadcast::auth()proxied to pooled instance B (empty channels array)Solution
Store channels directly on the singleton
BroadcastManagerinstead of proxying to pooled drivers:This ensures all channel registrations are shared across all pooled broadcaster instances while maintaining the performance benefits of connection pooling.
Changes
Breaking Changes
None. All existing methods and behavior are preserved. The fix only affects how channels are stored internally.