Skip to content

NoMethodError: undefined method rails for nil #2386

Closed

Description

Issue Description

In my server logs (but not in Sentry), I found another NoMethodError: This time, rails was called on nil.

Stack Trace of the Issue

NoMethodError (undefined method `rails' for nil):

sentry-rails (5.18.2) lib/sentry/rails/rescued_exception_interceptor.rb:20:in `report_rescued_exceptions?'
sentry-rails (5.18.2) lib/sentry/rails/rescued_exception_interceptor.rb:14:in `rescue in call'
sentry-rails (5.18.2) lib/sentry/rails/rescued_exception_interceptor.rb:11:in `call'
actionpack (7.1.3.4) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
sentry-ruby (5.18.2) lib/sentry/rack/capture_exceptions.rb:30:in `block (2 levels) in call'
sentry-ruby (5.18.2) lib/sentry/hub.rb:258:in `with_session_tracking'
sentry-ruby (5.18.2) lib/sentry-ruby.rb:404:in `with_session_tracking'
sentry-ruby (5.18.2) lib/sentry/rack/capture_exceptions.rb:21:in `block in call'
sentry-ruby (5.18.2) lib/sentry/hub.rb:59:in `with_scope'
sentry-ruby (5.18.2) lib/sentry-ruby.rb:384:in `with_scope'
sentry-ruby (5.18.2) lib/sentry/rack/capture_exceptions.rb:20:in `call'
actionpack (7.1.3.4) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (7.1.3.4) lib/rails/rack/logger.rb:37:in `call_app'
railties (7.1.3.4) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (7.1.3.4) lib/active_support/tagged_logging.rb:135:in `block in tagged'
activesupport (7.1.3.4) lib/active_support/tagged_logging.rb:39:in `tagged'
activesupport (7.1.3.4) lib/active_support/tagged_logging.rb:135:in `tagged'
activesupport (7.1.3.4) lib/active_support/broadcast_logger.rb:240:in `method_missing'
railties (7.1.3.4) lib/rails/rack/logger.rb:24:in `call'
actionpack (7.1.3.4) lib/action_dispatch/middleware/remote_ip.rb:92:in `call'
actionpack (7.1.3.4) lib/action_dispatch/middleware/request_id.rb:28:in `call'
rack (3.1.7) lib/rack/method_override.rb:28:in `call'
rack (3.1.7) lib/rack/runtime.rb:24:in `call'
actionpack (7.1.3.4) lib/action_dispatch/middleware/executor.rb:14:in `call'
rack (3.1.7) lib/rack/sendfile.rb:114:in `call'
actionpack (7.1.3.4) lib/action_dispatch/middleware/ssl.rb:79:in `call'
actionpack (7.1.3.4) lib/action_dispatch/middleware/assume_ssl.rb:21:in `call'
lib/middleware/web_socket_sentry_headers.rb:12:in `call'
mnemosyne-ruby (2.0.0) lib/mnemosyne/middleware/rack.rb:78:in `call'
telegraf (3.0.0) lib/telegraf/rack.rb:67:in `call'
railties (7.1.3.4) lib/rails/engine.rb:536:in `call'
rack (3.1.7) lib/rack/urlmap.rb:76:in `block in call'
rack (3.1.7) lib/rack/urlmap.rb:60:in `each'
rack (3.1.7) lib/rack/urlmap.rb:60:in `call'
puma (6.4.2) lib/puma/configuration.rb:272:in `call'
puma (6.4.2) lib/puma/request.rb:100:in `block in handle_request'
puma (6.4.2) lib/puma/thread_pool.rb:378:in `with_force_shutdown'
puma (6.4.2) lib/puma/request.rb:99:in `handle_request'
puma (6.4.2) lib/puma/server.rb:464:in `process_client'
puma (6.4.2) lib/puma/server.rb:245:in `block in run'
puma (6.4.2) lib/puma/thread_pool.rb:155:in `block in spawn_thread'

Reproduction Steps

Unfortunately, I don't have clear reproduction steps. I know that the error occurred during this trace and doesn't occur regularly.

The issue occurred as part of a WebSocket connection in a Rack hijack block.

Expected Behavior

No error is generated in Sentry, and rails can be called successfully.

Actual Behavior

A NoMethodError is raised, see above stack trace for details

Ruby Version

3.3.4

SDK Version

5.18.2

Integration and Its Version

Rails 7.1.3.4

Sentry Config

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions