From cb44aeb91b197e0c8d1a6d1e03f0f1fd99909c63 Mon Sep 17 00:00:00 2001 From: Gustavo Diel Date: Mon, 28 Oct 2024 13:07:05 -0300 Subject: [PATCH 1/2] fix: allow retrycount to be empty --- lib/sidekiq/silent_retry/server_middleware.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/sidekiq/silent_retry/server_middleware.rb b/lib/sidekiq/silent_retry/server_middleware.rb index f6561e5..972a865 100644 --- a/lib/sidekiq/silent_retry/server_middleware.rb +++ b/lib/sidekiq/silent_retry/server_middleware.rb @@ -17,7 +17,11 @@ def call(_job_instance, job_payload, _queue) private def should_warn?(job_payload) - job_payload["retry_count"] >= warn_after(job_payload) + retry_count = job_payload["retry_count"] + + return false if retry_count.nil? + + retry_count >= warn_after(job_payload) end def warn_after(job_payload) From 208fd3ac2035b72e67a963503f44f730e77b93e4 Mon Sep 17 00:00:00 2001 From: Gustavo Diel Date: Mon, 28 Oct 2024 13:08:06 -0300 Subject: [PATCH 2/2] refactor: rework if --- lib/sidekiq/silent_retry/server_middleware.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sidekiq/silent_retry/server_middleware.rb b/lib/sidekiq/silent_retry/server_middleware.rb index 972a865..adce343 100644 --- a/lib/sidekiq/silent_retry/server_middleware.rb +++ b/lib/sidekiq/silent_retry/server_middleware.rb @@ -19,7 +19,7 @@ def call(_job_instance, job_payload, _queue) def should_warn?(job_payload) retry_count = job_payload["retry_count"] - return false if retry_count.nil? + return false unless retry_count retry_count >= warn_after(job_payload) end