rails / rails

Ruby on Rails
https://rubyonrails.org
MIT License
55.74k stars 21.58k forks source link

[ActionCable] Rejecting a subscription in `before_subscribe` #52229

Open rsamoilov opened 3 months ago

rsamoilov commented 3 months ago

Steps to reproduce

Create an ActionCable channel that rejects a subscription in a before_subscribe hook:

class ChatChannel < ApplicationCable::Channel
  before_subscribe do
    reject
  end

  def subscribed
    Rails.logger.info("subscribed!")
  end
end

Expected behavior

The subscribed method does not get called. This is similar to the behaviour of regular controllers - the action does not get called if a before_action hook renders.

Actual behavior

The subscribed method gets called anyway.

System configuration

Rails version: 7.1.3.4

Ruby version: 3.3.3

rails-bot[bot] commented 2 days ago

This issue has been automatically marked as stale because it has not been commented on for at least three months. The resources of the Rails team are limited, and so we are asking for your help. If you can still reproduce this error on the 7-2-stable branch or on main, please reply with all of the information you have about it in order to keep the issue open. Thank you for all your contributions.

joshuay03 commented 2 hours ago

https://github.com/rails/rails/pull/53101