Skip to content

Background worker doesn't work for classic Sinatra apps #1778

@st0012

Description

@st0012

Issue Description

When being ran in classic mode and without config.ru (e.g. bundle exec ruby app.rb), Sinatra apps will be initialized at the end of the Ruby script by a at_exit callback. And that means that the SDK's at_exit callback will also be called:

at_exit do
@session_flusher&.kill
@background_worker.shutdown
end

So when app.rb is loaded, the SDK's background worker is also disabled 🙈 Therefore, no event will be sent by the SDK.

Reproduction Steps

Script

# app.rb
require 'sinatra'
require 'sentry-ruby'

Sentry.init do |config|
  config.dsn = 'DSN'
end

use Sentry::Rack::CaptureExceptions

get "/" do
  raise "foo"
end

Command

$ bundle exec ruby app.rb

Expected Behavior

Errors will be reported.

Actual Behavior

Errors are not reported because the background worker is shut down unexpectedly.

Ruby Version

3.1.0

SDK Version

5.2.1 & master

Integration and Its Version

No response

Sentry Config

No response

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions