Sentry-ruby: sentry-rails: Impossible to start a rails 6 server with constant autoloading

Created on 11 Feb 2021  路  3Comments  路  Source: getsentry/sentry-ruby

Describe the bug
Impossible to start a rails 6 server with constant autoloading.

To Reproduce
Start a rails 6 (with zeitwerk autoloader) with gem sentry-rails.
With this rails configuration: config.eager_load = true

Expected behavior
Rails starts

Actual behavior
Rails Boot error:
Zeitwerk::NameError: expected file /opt/app/vendor/bundle/ruby/2.7.0/gems/sentry-rails-4.2.1/app/jobs/sentry/send_event_job.rb to define constant Sentry::SendEventJob, but didn't

Because of this line:
https://github.com/getsentry/sentry-ruby/blob/master/sentry-rails/app/jobs/sentry/send_event_job.rb#L1

Environment
$ ruby --version
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
$ rails --version
Rails 6.0.3.4
$ bundle info sentry-rails

  • sentry-rails (4.2.1)
bug sentry-rails

Most helpful comment

@cyrilchampier thanks for the information, I can reproduce it now. I have added a PR to fix it.

All 3 comments

does your application exclude ActiveJob? if you have Rails installed, ActiveJob should be defined and that line shouldn't be triggered. I can't reproduce this with the Rails applications I have.

Here are my application.rb requires:

require 'rails'
require 'active_record/railtie'
require 'action_controller/railtie'
require 'action_view/railtie'
require 'rails/test_unit/railtie'
require 'sprockets/railtie'

If I add require 'active_job/railtie', the server can start.

But that means that line
return unless defined?(ActiveJob)
force me to add action_job as dependency of my project :(

@cyrilchampier thanks for the information, I can reproduce it now. I have added a PR to fix it.

Was this page helpful?
0 / 5 - 0 ratings