aboutsummaryrefslogtreecommitdiffstats
path: root/activejob
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2018-09-18 14:35:39 -0400
committerGitHub <noreply@github.com>2018-09-18 14:35:39 -0400
commit1b90f614b1b3d06b7f02a8b9ea6cd84f15d58643 (patch)
tree4f56f766914c46f0767e636399a7c7c939bbde16 /activejob
parentafea273960e286712c86c272015a6a4767677992 (diff)
parentb6b5a7ac524a8c22d9ca162e53d752141f974651 (diff)
downloadrails-1b90f614b1b3d06b7f02a8b9ea6cd84f15d58643.tar.gz
rails-1b90f614b1b3d06b7f02a8b9ea6cd84f15d58643.tar.bz2
rails-1b90f614b1b3d06b7f02a8b9ea6cd84f15d58643.zip
Merge pull request #33897 from bogdanvlviv/follow-up-33751
Follow up #33751
Diffstat (limited to 'activejob')
-rw-r--r--activejob/lib/active_job/exceptions.rb28
-rw-r--r--activejob/lib/active_job/logging.rb2
-rw-r--r--activejob/test/cases/logging_test.rb5
3 files changed, 23 insertions, 12 deletions
diff --git a/activejob/lib/active_job/exceptions.rb b/activejob/lib/active_job/exceptions.rb
index d8384c81b6..bb25afbca6 100644
--- a/activejob/lib/active_job/exceptions.rb
+++ b/activejob/lib/active_job/exceptions.rb
@@ -46,18 +46,15 @@ module ActiveJob
# end
def retry_on(*exceptions, wait: 3.seconds, attempts: 5, queue: nil, priority: nil)
rescue_from(*exceptions) do |error|
- payload = {
- job: self,
- adapter: self.class.queue_adapter,
- error: error,
- wait: wait
- }
-
if executions < attempts
- ActiveSupport::Notifications.instrument("enqueue_retry.active_job", payload) do
- retry_job wait: determine_delay(wait), queue: queue, priority: priority
- end
+ retry_job wait: determine_delay(wait), queue: queue, priority: priority, error: error
else
+ payload = {
+ job: self,
+ adapter: self.class.queue_adapter,
+ error: error
+ }
+
if block_given?
ActiveSupport::Notifications.instrument("retry_stopped.active_job", payload) do
yield self, error
@@ -127,7 +124,16 @@ module ActiveJob
# end
# end
def retry_job(options = {})
- enqueue options
+ payload = {
+ job: self,
+ adapter: self.class.queue_adapter,
+ error: options[:error],
+ wait: options[:wait]
+ }
+
+ ActiveSupport::Notifications.instrument("enqueue_retry.active_job", payload) do
+ enqueue options
+ end
end
private
diff --git a/activejob/lib/active_job/logging.rb b/activejob/lib/active_job/logging.rb
index 96a3e6bf48..0abee4ed98 100644
--- a/activejob/lib/active_job/logging.rb
+++ b/activejob/lib/active_job/logging.rb
@@ -94,7 +94,7 @@ module ActiveJob
wait = event.payload[:wait]
error do
- "Retrying #{job.class} in #{wait} seconds, due to a #{ex.class}. The original exception was #{ex.cause.inspect}."
+ "Retrying #{job.class} in #{wait.inspect} seconds, due to a #{ex&.class.inspect}. The original exception was #{ex&.cause.inspect}."
end
end
diff --git a/activejob/test/cases/logging_test.rb b/activejob/test/cases/logging_test.rb
index 2e8d2ef7c0..b5bf40c83b 100644
--- a/activejob/test/cases/logging_test.rb
+++ b/activejob/test/cases/logging_test.rb
@@ -173,6 +173,11 @@ class LoggingTest < ActiveSupport::TestCase
end
end
+ def test_enqueue_retry_logging_on_retry_job
+ perform_enqueued_jobs { RescueJob.perform_later "david" }
+ assert_match(/Retrying RescueJob in nil seconds, due to a nil\. The original exception was nil\./, @logger.messages)
+ end
+
def test_retry_stopped_logging
perform_enqueued_jobs do
RetryJob.perform_later "CustomCatchError", 6