Skip to content

Commit bc3de42

Browse files
authored
(fix) crons: require sidekiq-cron early (#2173)
1 parent 16ef3e7 commit bc3de42

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

sentry-sidekiq/lib/sentry/sidekiq/cron/job.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# frozen_string_literal: true
22

3-
return unless defined?(::Sidekiq::Cron::Job)
3+
# Try requiring sidekiq-cron to ensure it's loaded before the integration.
4+
# If sidekiq-cron is not available, do nothing.
5+
begin
6+
require "sidekiq-cron"
7+
rescue LoadError
8+
return
9+
end
410

511
module Sentry
612
module Sidekiq

sentry-sidekiq/spec/sentry/sidekiq/cron/job_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
before do
1111
schedule_file = 'spec/fixtures/schedule.yml'
1212
schedule = Sidekiq::Cron::Support.load_yaml(ERB.new(IO.read(schedule_file)).result)
13-
Sidekiq::Cron::Job.load_from_hash!(schedule, source: 'schedule')
13+
# sidekiq-cron 2.0+ accepts second argument to `load_from_hash!` with options,
14+
# such as {source: 'schedule'}, but sidekiq-cron 1.9.1 (last version to support Ruby 2.6) does not.
15+
# Since we're not using the source option in our code anyway, it's safe to not pass the 2nd arg.
16+
Sidekiq::Cron::Job.load_from_hash!(schedule)
1417
end
1518

1619
it 'patches class' do

0 commit comments

Comments
 (0)