Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: consider zero when retry_count not present #7

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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