-
-
Notifications
You must be signed in to change notification settings - Fork 538
fix(rails): make Action Cable handle_open/handle_close overrides public for Rails 8.2 #2972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,8 +57,13 @@ def finish_transaction(transaction, status_code) | |
| end | ||
|
|
||
| module Connection | ||
| private | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to do this conditionally, otherwise on older Rails version we'd be changing method visibility, and that would be an unwanted side-effect. |
||
|
|
||
| # These overrides must stay public: Rails 8.2 decoupled the Action | ||
| # Cable connection from the socket (rails/rails#50979), and | ||
| # ActionCable::Server::Socket now invokes connection.handle_open and | ||
| # connection.handle_close from outside the connection. With private | ||
| # overrides every cable connection raises NoMethodError before the | ||
| # welcome message is sent. On older Rails versions these methods are | ||
| # only called internally, so public visibility is harmless there. | ||
| def handle_open | ||
| ErrorHandler.capture(self, transaction_name: "#{self.class.name}#connect") do | ||
| super | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,20 @@ def disconnect | |
| transport.events = [] | ||
| end | ||
|
|
||
| describe "Connection method visibility" do | ||
| before do | ||
| make_basic_app | ||
| end | ||
|
|
||
| # Rails 8.2 (rails/rails#50979) invokes connection.handle_open and | ||
| # connection.handle_close from ActionCable::Server::Socket, outside the | ||
| # connection — private overrides break every cable connection there. | ||
| it "keeps handle_open and handle_close public" do | ||
| expect(Sentry::Rails::ActionCableExtensions::Connection.public_method_defined?(:handle_open)).to eq(true) | ||
| expect(Sentry::Rails::ActionCableExtensions::Connection.public_method_defined?(:handle_close)).to eq(true) | ||
| end | ||
| end | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This tests implementation details. I assume that under Rails 8.2 some of our specs would fail, right? If they do, then this test is redundant, if they don't, then it would be good to reproduce the issue under 8.2 by exercising the actual behavior that Sentry adds. |
||
|
|
||
| describe "Connection" do | ||
| before do | ||
| make_basic_app | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to update this as CHANGELOG is now updated automatically during the release process 🪄