Skip to content
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

Directly execute ActionCable's action if the SDK is not initialized #1692

Merged
merged 2 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### Bug Fixes

- Directly execute ActionCable's action if the SDK is not initialized [#1692](https://github.com/getsentry/sentry-ruby/pull/1692)
- Fixes [#1691](https://github.com/getsentry/sentry-ruby/issues/1691)

## 4.9.1

### Bug Fixes
Expand Down
1 change: 1 addition & 0 deletions sentry-rails/lib/sentry/rails/action_cable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module ActionCableExtensions
class ErrorHandler
class << self
def capture(connection, transaction_name:, extra_context: nil, &block)
return block.call unless Sentry.initialized?
# ActionCable's ConnectionStub (for testing) doesn't implement the exact same interfaces as Connection::Base.
# One thing that's missing is `env`. So calling `connection.env` direclty will fail in test environments when `stub_connection` is used.
# See https://github.com/getsentry/sentry-ruby/pull/1684 for more information.
Expand Down
13 changes: 13 additions & 0 deletions sentry-rails/spec/sentry/rails/action_cable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ def disconnect
end
end

RSpec.describe "without Sentry initialized" do
before do
allow(Sentry).to receive(:get_main_hub).and_return(nil)
make_basic_app
Sentry.clone_hub_to_current_thread # make sure the thread doesn't set a hub
end

describe ChatChannel, type: :channel do
it "doesn't swallow the app's operation" do
expect { subscribe }.to raise_error('foo')
end
end
end

RSpec.describe "Sentry::Rails::ActionCableExtensions", type: :channel do
let(:transport) { Sentry.get_current_client.transport }
Expand Down
2 changes: 1 addition & 1 deletion sentry-ruby/lib/sentry-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def init(&block)
#
# @return [Boolean]
def initialized?
!!@main_hub
!!get_main_hub
end

# Returns an uri for security policy reporting that's generated from the given DSN
Expand Down