fix(rails): make Action Cable handle_open/handle_close overrides public for Rails 8.2#2972
Open
kylekeesling wants to merge 1 commit into
Open
Conversation
Rails 8.2 decoupled the Action Cable connection from the socket (rails/rails#50979): ActionCable::Server::Socket now invokes connection.handle_open and connection.handle_close from outside the connection. sentry-rails' prepended overrides were private, so on Rails main every cable connection raises NoMethodError (private method 'handle_open' called for an instance of ApplicationCable::Connection) before the welcome message is sent — clients never receive pings or broadcasts and reconnect in a loop. The error only reaches the Rails logger (Sentry isn't initialized for the failing connection path), so it fails silently. On Rails < 8.2 these methods are only called internally on self, where visibility doesn't matter, so making them public is safe everywhere. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Description
Rails 8.2 decoupled the Action Cable connection from the socket in rails/rails#50979 (merged 2026-05-28):
ActionCable::Server::Socketnow invokesconnection.handle_openandconnection.handle_closefrom outside the connection object.Sentry::Rails::ActionCableExtensions::Connectiondeclares itshandle_open/handle_closeoverrides asprivate, which shadows the (public) framework methods through the prepend chain. On Rails main / 8.2, every cable connection then raises:before the
welcomemessage is sent. The practical effect is severe and silent: the WebSocket upgrade succeeds (101), but clients never receivewelcomeor pings, so they treat the connection as stale and reconnect in a loop forever — no broadcasts (e.g. Turbo Streams) are ever delivered. The exception only hits the Rails logger, not Sentry, since it occurs in the instrumentation wrapper itself.We hit this in production on a Rails edge app with sentry-rails 6.6.0 and confirmed the root cause by inspecting method visibility:
Fix
Make the two overrides public. On Rails < 8.2 they are only invoked internally on
self(visibility is irrelevant there), so this is safe across all supported Rails versions. Added a regression spec asserting the visibility and a changelog entry.bundle exec rspec spec/sentry/rails/action_cable_spec.rb→ 12 examples, 0 failures.