Comments (2)
It looks like for channels, only public actions declared by the user are rescue-able and not callbacks like #subscribed
:
rails/actioncable/lib/action_cable/channel/base.rb
Lines 173 to 187 in 965b8c3
For connections since the test works, I think there isn't a problem here.
There is already a test for this:
rails/actioncable/test/connection/subscriptions_test.rb
Lines 116 to 127 in 965b8c3
Maybe we could add a test for not supporting rescue_from
in non-user callbacks (like subscribed
).
from rails.
only public actions declared by the user are rescue-able
Looks like only #subscribed and #unsubscribed are not rescue-able.
You can still use rescue_from by doing something like this:
def subscribed
# ...
rescue StandardError => e
rescue_with_handler(e)
end
But I still find it a bit confusing that these two actions are exceptions to rescue_from
, as their behavior is defined inside the channel.
This is the current #subscribe_to_channel method which calls #subscribed:
rails/actioncable/lib/action_cable/channel/base.rb
Lines 191 to 198 in 965b8c3
Maybe using rescue_with_handler
in this method could be a good solution?
def subscribe_to_channel
run_callbacks :subscribe do
subscribed
end
rescue Exception => exception
rescue_with_handler(exception) || raise
ensure
reject_subscription if subscription_rejected?
ensure_confirmation_sent
end
And something similar with #unsubscribe_from_channel.
from rails.
Related Issues (20)
- [BUG since 2016] cookies.delete does not remove cookies for subsequent requests (ActionController::TestCase) HOT 2
- "Polymorphic associations do not support computing the class." error when creating a record with a `has_one :through` HOT 4
- Null error in DB on relation `belongs_to` HOT 1
- Relax the sqlite3 dependency for Rails 7.1 HOT 4
- [DOC] active record basic guide said `create` would return `false` if failed
- ActiveRecord `attribute :foo, :bar` requires an active connection
- enable_extension in schema dump doesn't contain schema name HOT 6
- PostgreSQL array not decrypting HOT 2
- Behaviour of `autosave` associations has changed on edge HOT 5
- [ActiveRecord] delete_all on has_many with dependent: :restrict_with_error results with nullify HOT 2
- ActiveRecord::AttributeMethods::Serialization::ClassMethods.serialize is not backwards compatible 7.0 -> 7.1 HOT 6
- ActiveRecord: Issue with NULL insertion for serialized empty arrays causing database constraint violations HOT 1
- daterange with `.contains(Date)` results in malformed SQL ActiveRecord::StatementInvalid: PG::InvalidTextRepresentation: ERROR: malformed range literal: "2024-07-17"
- Custom Validators that rely on Date Comparison are now breaking in Rails 7.1/Spec test cases HOT 6
- ActiveRecord CPK issue with lookup by associations HOT 2
- Leveraging button form attribute to simplify front-end integration HOT 1
- [Doc][7.2] Migration versions [8.0] are mixed up in active_record_migrations.md HOT 1
- FormHelper#text_field build value attribute of IPAddr without prefix
- Callbacks / Validations not running for `accepts_nested_attributes_for` relation on certain values, but will run on other values, or when another value is saved together with the problematic value, or when updating the record directly HOT 6
- Rails 7.0: `form_with` does not prefix id with namespace when namespace is given HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rails.