ActionCableSubscription#perform now returns a promise#46
Open
cmdoptesc wants to merge 1 commit intoanycable:masterfrom
Open
ActionCableSubscription#perform now returns a promise#46cmdoptesc wants to merge 1 commit intoanycable:masterfrom
cmdoptesc wants to merge 1 commit intoanycable:masterfrom
Conversation
So this deviates from the ActionCable JS client a where it returns a boolean: https://github.com/rails/rails/blob/242216803ee73f528b0a74c6bdb367e5b98d8f83/actioncable/app/assets/javascripts/action_cable.js#L318 Long trace of ActionCable.Subscriptions -> ActionCable.Consumer: https://github.com/rails/rails/blob/242216803ee73f528b0a74c6bdb367e5b98d8f83/actioncable/app/assets/javascripts/action_cable.js#L140 But for our purposes, we noticed sometimes AnyCable's ActionCableSubscription#perform is called on a closed subscription and raises an error (should now be adjustable in 0.9.2 thanks!), but it would be nice to catch and handle those errors. Channel#perform already surfaces the promise, so why not just surface it one more level? https://github.com/anycable/anycable-client/blob/62674a8207b6add893677369106766c7baa234f4/packages/core/channel/index.js#L120
Member
Good catch. I think, a proper fix would be to return boolean as well (and check the connection state to return false when it's closed). Otherwise our implementation would deviate even more from the Action Cable one. That doesn't help with the original goal—catching errors. But for that, I think, the right way is to use AnyCable channels instead of the Action Cable wrapper. |
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.
So this deviates from the ActionCable JS client a where it returns a boolean:
https://github.com/rails/rails/blob/242216803ee73f528b0a74c6bdb367e5b98d8f83/actioncable/app/assets/javascripts/action_cable.js#L318
Long trace of ActionCable.Subscriptions -> ActionCable.Consumer: https://github.com/rails/rails/blob/242216803ee73f528b0a74c6bdb367e5b98d8f83/actioncable/app/assets/javascripts/action_cable.js#L140
But for our purposes, we noticed sometimes AnyCable's ActionCableSubscription#perform is called on a closed subscription and raises an error (should now be adjustable in 0.9.2 thanks!), but it would be nice to catch and handle those errors.
Channel#perform already surfaces the promise, so why not just surface it one more level?
anycable-client/packages/core/channel/index.js
Line 120 in 62674a8