Skip to content

Commit

Permalink
Merge pull request #7 from IgorFroehner/IgorFroehner/fix-when-retry-c…
Browse files Browse the repository at this point in the history
…ount-is-not-present

fix: consider zero when retry_count not present
  • Loading branch information
gustavodiel authored Oct 28, 2024
2 parents e7dcdb2 + de3b111 commit ae9f590
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sidekiq/silent_retry/server_middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def call(_job_instance, job_payload, _queue)
private

def should_warn?(job_payload)
job_payload["retry_count"] >= warn_after(job_payload)
(job_payload["retry_count"] || 0) >= warn_after(job_payload)
end

def warn_after(job_payload)
Expand Down
25 changes: 25 additions & 0 deletions spec/sidekiq/silent_retry/server_middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,31 @@
}
end

context 'in the first failure' do
let(:job_payload) do
{
"retry" => 2,
"silent_retry" => silent_retry
}
end

context 'with silent retry enabled' do
let(:silent_retry) { true }

it 'raises the silent error' do
expect { subject }.to raise_error(Sidekiq::SilentRetry.silent_retry_error_class, "some message")
end
end

context 'with silent retry disabled' do
let(:silent_retry) { false }

it 'raises the error' do
expect { subject }.to raise_error(StandardError, "some message")
end
end
end

context "when silent retry is off" do
let(:silent_retry) { false }

Expand Down

0 comments on commit ae9f590

Please sign in to comment.