Repository navigation
Conversation
CableReady::Updatable passed the model class and the record's GlobalID object to ActionCable.server.broadcast, while subscribers stream from compound(keys), a String. Stock Action Cable calls String() on the broadcasting, so the names matched, but servers that transform non-String broadcastings (AnyCable 1.5+ uses to_gid_param/to_param, which base64-encodes a GlobalID) publish record updates to a stream nobody subscribes to. Build the broadcasting with compound, like the subscribe side does.
👷 Deploy request for cableready pending review.Visit the deploys page to approve it
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Type of PR
Bug fix
Description
CableReady::Updatable#broadcast_updatespasses the model class, and for record updates the record'sGlobalIDobject, straight toActionCable.server.broadcast(updatable.rb#L198, #L201; callers in model_updatable_callbacks.rb#L21-L29). Subscribers stream fromcompound(keys), a String built withto_global_id.to_s(view_helper.rb#L54-L57, compoundable.rb#L5-L9).Stock Action Cable calls
String(broadcasting)inbroadcaster_for(Rails main; same in 7.2), so the two sides agree. Since anycable-rails 1.5 (anycable/anycable-rails@594f339),broadcaster_forruns non-String broadcastings throughAnyCable::Rails.stream_name_from, i.e.try(:to_gid_param) || to_param(broadcast_options.rb#L14-L17, rails.rb#L64-L70).GlobalID#to_paramis base64, so record updates are published toZ2lkOi8v...while thecable_ready_updates_for(record)element listens ongid://.... Those updates are silently dropped. The extension is loaded by the railtie whatever adapter is configured, so this happens with the async and test adapters too.This change builds the broadcasting with
compound, the same helper the subscribe side uses, soActionCable.server.broadcastalways receives a String. On stock Action Cable the resulting name is the same as before (String(User) == "User",String(gid) == gid.to_s), so this is a no-op there.Why should this be added
In apps running anycable-rails >= 1.5,
cable_ready_updates_for(record)stops receiving updates. Class-level and collection-level updates are unaffected. Without this fix, the workaround is to overrideActionCable::Server::Base#broadcaster_forapp-wide, which also disables AnyCable's own handling of streamable broadcastings.Tests
compoundstream name. It fails without the fix.User/user.to_global_idto"User"/user.to_global_id.to_s.bundle exec rake test: 89 runs, 0 failures.Checklist