Skip to content

ThreadError resque:no_fork resque:work New Level: Error Unhandled can't be called from trap context (ThreadError) #2520

@iuliabirleanu

Description

@iuliabirleanu

Issue Description

When trying to upgrade our sentry-ruby version from 5.21.0 to the latest 5.22.1, I noticed the following error:

ThreadError resque:no_fork resque:work
Unhandled
can't be called from trap context (ThreadError)

The trace indicates the error is coming from sentry-ruby/lib/sentry-ruby.rb at line 310 from inside get_main_hub.
get_main_hub was indeed updated in the last release, but I can not say why is generating the error above.

Trace:
/usr/bundle/ruby/3.3.0/gems/sentry-ruby-5.22.1/lib/sentry-ruby.rb:310:in synchronize' /usr/bundle/ruby/3.3.0/gems/sentry-ruby-5.22.1/lib/sentry-ruby.rb:310:in get_main_hub'
/usr/bundle/ruby/3.3.0/gems/sentry-ruby-5.22.1/lib/sentry-ruby.rb:290:in initialized?' /usr/bundle/ruby/3.3.0/gems/sentry-ruby-5.22.1/lib/sentry/breadcrumb/sentry_logger.rb:25:in add_breadcrumb'
/usr/bundle/ruby/3.3.0/gems/sentry-ruby-5.22.1/lib/sentry/breadcrumb/sentry_logger.rb:18:in add' /usr/bundle/ruby/3.3.0/gems/logger-1.6.5/lib/logger.rb:702:in info'
/usr/bundle/ruby/3.3.0/gems/resque-1.27.4/lib/resque/logging.rb:8:in log' /usr/bundle/ruby/3.3.0/gems/resque-1.27.4/lib/resque/worker.rb:917:in log_with_severity'
/usr/bundle/ruby/3.3.0/gems/resque-1.27.4/lib/resque/worker.rb:424:in shutdown' /usr/bundle/ruby/3.3.0/gems/resque-1.27.4/lib/resque/worker.rb:387:in block in register_signal_handlers'
/usr/bundle/ruby/3.3.0/gems/resque-1.27.4/lib/resque/worker.rb:238:in sleep' /usr/bundle/ruby/3.3.0/gems/resque-1.27.4/lib/resque/worker.rb:238:in block in work'
internal:kernel:187:in loop' /usr/bundle/ruby/3.3.0/gems/resque-1.27.4/lib/resque/worker.rb:231:in work'
/usr/bundle/ruby/3.3.0/gems/resque-1.27.4/lib/resque/tasks.rb:20:in block (2 levels) in <top (required)>' /usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/task.rb:281:in block in execute'
/usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/task.rb:281:in each' /usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/task.rb:281:in execute'
/usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/task.rb:219:in block in invoke_with_call_chain' /usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/task.rb:199:in synchronize'
/usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/task.rb:199:in invoke_with_call_chain' /usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/task.rb:188:in invoke'
/usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:188:in invoke_task' /usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:138:in block (2 levels) in top_level'
/usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:138:in each' /usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:138:in block in top_level'
/usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:147:in run_with_threads' /usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:132:in top_level'
/usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:83:in block in run' /usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:214:in standard_exception_handling'
/usr/bundle/ruby/3.3.0/gems/rake-13.2.1/lib/rake/application.rb:80:in run' /usr/bundle/ruby/3.3.0/gems/rake-13.2.1/exe/rake:27:in <top (required)>'
/usr/bundle/ruby/3.3.0/bin/rake:25:in load' /usr/bundle/ruby/3.3.0/bin/rake:25:in <top (required)>'
/usr/bundle/gems/bundler-2.5.18/lib/bundler/cli/exec.rb:58:in load' /usr/bundle/gems/bundler-2.5.18/lib/bundler/cli/exec.rb:58:in kernel_load'
/usr/bundle/gems/bundler-2.5.18/lib/bundler/cli/exec.rb:23:in run' /usr/bundle/gems/bundler-2.5.18/lib/bundler/cli.rb:455:in exec'
/usr/bundle/gems/bundler-2.5.18/lib/bundler/vendor/thor/lib/thor/command.rb:28:in run' /usr/bundle/gems/bundler-2.5.18/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in invoke_command'
/usr/bundle/gems/bundler-2.5.18/lib/bundler/vendor/thor/lib/thor.rb:527:in dispatch' /usr/bundle/gems/bundler-2.5.18/lib/bundler/cli.rb:35:in dispatch'
/usr/bundle/gems/bundler-2.5.18/lib/bundler/vendor/thor/lib/thor/base.rb:584:in start' /usr/bundle/gems/bundler-2.5.18/lib/bundler/cli.rb:29:in start'
/usr/bundle/gems/bundler-2.5.18/exe/bundle:28:in block in <top (required)>' /usr/bundle/gems/bundler-2.5.18/lib/bundler/friendly_errors.rb:117:in with_friendly_errors'
/usr/bundle/gems/bundler-2.5.18/exe/bundle:20:in <top (required)>' /usr/bin/bundle:25:in load'
/usr/bin/bundle:25:in `

'

The error still happens despite #2510 being merged.

Reproduction Steps

It happens when a resque worker shuts down, but not on every shut down.

Expected Behavior

The error mentioned above should not be present.

Actual Behavior

The error mentioned above is present.

Ruby Version

3.3.6

SDK Version

5.21 - 5.22

Integration and Its Version

Rails 7.0.8.7

Sentry Config

Exceptions.configure do |config|
config.sentry.with(
enabled: ENV.fetch('SENTRY_ENABLED', 'false') == 'true',
dsn: ENV.fetch('SENTRY_DSN', nil)
)
config.generate_fingerprint = false
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions