From 3f7f8878417bb034f97738de38d5e094bad0e65e Mon Sep 17 00:00:00 2001 From: f Date: Thu, 28 Mar 2024 10:13:13 -0300 Subject: [PATCH] fix: activejob gestiona errores por su cuenta closes #15351 closes #15352 closes #15612 closes #15618 closes #15621 closes #15622 closes #15623 closes #15729 closes #15730 closes #15731 closes #15735 closes #15736 closes #15776 closes #15824 closes #15827 closes #15828 closes #15829 closes #15830 closes #15831 closes #15832 closes #15838 closes #15839 closes #15882 --- app/jobs/activity_pub/fetch_job.rb | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/app/jobs/activity_pub/fetch_job.rb b/app/jobs/activity_pub/fetch_job.rb index 54641dbf..0a3ebf03 100644 --- a/app/jobs/activity_pub/fetch_job.rb +++ b/app/jobs/activity_pub/fetch_job.rb @@ -19,25 +19,16 @@ class ActivityPub # # @param error [Exception] # @return [Bool] - def handle_error(error) - case error - when FastJsonparser::ParseError - expire - - ExceptionNotifier.notify_exception(error, data: { site: site.name, object: object.uri, body: response.body }) - - false - when ActiveRecord::RecordInvalid, SocketError, SystemCallError, Net::OpenTimeout, OpenSSL::OpenSSLError - retry_in(ApplicationJob.random_wait) - - false - else - expire - - true - end + discard_on(FastJsonparser::ParseError) do |error| + ExceptionNotifier.notify_exception(error, data: { site: site.name, object: object.uri, body: response.body }) end + retry_on ActiveRecord::RecordInvalid + retry_on SocketError, wait: ApplicationJob.random_wait + retry_on SystemCallError, wait: ApplicationJob.random_wait + retry_on Net::OpenTimeout, wait: ApplicationJob.random_wait + retry_on OpenSSL::OpenSSLError, wait: ApplicationJob.random_wait + def perform(site:, object_id:) ActivityPub::Object.transaction do @site = site