From fe3da1a893c12b220309c696c3863b459f0400f0 Mon Sep 17 00:00:00 2001 From: Ivan Novosad Date: Fri, 8 Nov 2024 13:16:52 +0100 Subject: [PATCH] misc(nango): Increase the number of job retries in case of RequestLimitError (#2798) ## Context When generating a lot of invoices at once, Nango starts failing with `Request Limit Exceeded ` error ## Description This PR increases the number of attempts it makes to retry the failed jobs. We're changing it from 10 to 100 attempts with `wait: :polynomially_longer`. --- app/jobs/integrations/aggregator/credit_notes/create_job.rb | 2 +- app/jobs/integrations/aggregator/fetch_items_job.rb | 2 +- app/jobs/integrations/aggregator/invoices/create_job.rb | 2 +- .../aggregator/invoices/crm/create_customer_association_job.rb | 2 +- app/jobs/integrations/aggregator/invoices/crm/create_job.rb | 2 +- app/jobs/integrations/aggregator/invoices/crm/update_job.rb | 2 +- app/jobs/integrations/aggregator/payments/create_job.rb | 2 +- app/jobs/integrations/aggregator/perform_sync_job.rb | 2 +- app/jobs/integrations/aggregator/sales_orders/create_job.rb | 2 +- app/jobs/integrations/aggregator/send_restlet_endpoint_job.rb | 2 +- .../subscriptions/crm/create_customer_association_job.rb | 2 +- .../integrations/aggregator/subscriptions/crm/create_job.rb | 2 +- .../integrations/aggregator/subscriptions/crm/update_job.rb | 2 +- .../integrations/hubspot/companies/deploy_properties_job.rb | 2 +- app/jobs/integrations/hubspot/contacts/deploy_properties_job.rb | 2 +- app/jobs/integrations/hubspot/invoices/deploy_object_job.rb | 2 +- app/jobs/integrations/hubspot/save_portal_id_job.rb | 1 + .../integrations/hubspot/subscriptions/deploy_object_job.rb | 2 +- 18 files changed, 18 insertions(+), 17 deletions(-) diff --git a/app/jobs/integrations/aggregator/credit_notes/create_job.rb b/app/jobs/integrations/aggregator/credit_notes/create_job.rb index b1f3384bdee..eb0bd189660 100644 --- a/app/jobs/integrations/aggregator/credit_notes/create_job.rb +++ b/app/jobs/integrations/aggregator/credit_notes/create_job.rb @@ -7,7 +7,7 @@ class CreateJob < ApplicationJob queue_as 'integrations' retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 - retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(credit_note:) result = Integrations::Aggregator::CreditNotes::CreateService.call(credit_note:) diff --git a/app/jobs/integrations/aggregator/fetch_items_job.rb b/app/jobs/integrations/aggregator/fetch_items_job.rb index 97255a13e8a..061c7d4560f 100644 --- a/app/jobs/integrations/aggregator/fetch_items_job.rb +++ b/app/jobs/integrations/aggregator/fetch_items_job.rb @@ -6,7 +6,7 @@ class FetchItemsJob < ApplicationJob queue_as 'integrations' retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 - retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(integration:) result = Integrations::Aggregator::ItemsService.call(integration:) diff --git a/app/jobs/integrations/aggregator/invoices/create_job.rb b/app/jobs/integrations/aggregator/invoices/create_job.rb index 96a817925c3..75218dd026a 100644 --- a/app/jobs/integrations/aggregator/invoices/create_job.rb +++ b/app/jobs/integrations/aggregator/invoices/create_job.rb @@ -7,7 +7,7 @@ class CreateJob < ApplicationJob queue_as 'integrations' retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 - retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(invoice:) result = Integrations::Aggregator::Invoices::CreateService.call(invoice:) diff --git a/app/jobs/integrations/aggregator/invoices/crm/create_customer_association_job.rb b/app/jobs/integrations/aggregator/invoices/crm/create_customer_association_job.rb index 42f6eb9d61d..dbf980328b5 100644 --- a/app/jobs/integrations/aggregator/invoices/crm/create_customer_association_job.rb +++ b/app/jobs/integrations/aggregator/invoices/crm/create_customer_association_job.rb @@ -8,7 +8,7 @@ class CreateCustomerAssociationJob < ApplicationJob queue_as 'integrations' retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10 - retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(invoice:) result = Integrations::Aggregator::Invoices::Crm::CreateCustomerAssociationService.call(invoice:) diff --git a/app/jobs/integrations/aggregator/invoices/crm/create_job.rb b/app/jobs/integrations/aggregator/invoices/crm/create_job.rb index 59b359a2e8d..44155e8a363 100644 --- a/app/jobs/integrations/aggregator/invoices/crm/create_job.rb +++ b/app/jobs/integrations/aggregator/invoices/crm/create_job.rb @@ -9,7 +9,7 @@ class CreateJob < ApplicationJob retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10 retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10 - retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(invoice:) result = Integrations::Aggregator::Invoices::Crm::CreateService.call(invoice:) diff --git a/app/jobs/integrations/aggregator/invoices/crm/update_job.rb b/app/jobs/integrations/aggregator/invoices/crm/update_job.rb index 03cef69a97a..45418dd6eea 100644 --- a/app/jobs/integrations/aggregator/invoices/crm/update_job.rb +++ b/app/jobs/integrations/aggregator/invoices/crm/update_job.rb @@ -9,7 +9,7 @@ class UpdateJob < ApplicationJob retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10 retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10 - retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(invoice:) result = Integrations::Aggregator::Invoices::Crm::UpdateService.call(invoice:) diff --git a/app/jobs/integrations/aggregator/payments/create_job.rb b/app/jobs/integrations/aggregator/payments/create_job.rb index fc1c5323834..50c7283a553 100644 --- a/app/jobs/integrations/aggregator/payments/create_job.rb +++ b/app/jobs/integrations/aggregator/payments/create_job.rb @@ -7,7 +7,7 @@ class CreateJob < ApplicationJob queue_as 'integrations' retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 5 - retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(payment:) result = Integrations::Aggregator::Payments::CreateService.call(payment:) diff --git a/app/jobs/integrations/aggregator/perform_sync_job.rb b/app/jobs/integrations/aggregator/perform_sync_job.rb index 5fbe42b21d9..6ae1c5fae28 100644 --- a/app/jobs/integrations/aggregator/perform_sync_job.rb +++ b/app/jobs/integrations/aggregator/perform_sync_job.rb @@ -6,7 +6,7 @@ class PerformSyncJob < ApplicationJob queue_as 'integrations' retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 - retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(integration:, sync_items: true) sync_result = Integrations::Aggregator::SyncService.call(integration:) diff --git a/app/jobs/integrations/aggregator/sales_orders/create_job.rb b/app/jobs/integrations/aggregator/sales_orders/create_job.rb index abb4f03ad00..1693e36d742 100644 --- a/app/jobs/integrations/aggregator/sales_orders/create_job.rb +++ b/app/jobs/integrations/aggregator/sales_orders/create_job.rb @@ -7,7 +7,7 @@ class CreateJob < ApplicationJob queue_as 'integrations' retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 - retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(invoice:) result = Integrations::Aggregator::SalesOrders::CreateService.call(invoice:) diff --git a/app/jobs/integrations/aggregator/send_restlet_endpoint_job.rb b/app/jobs/integrations/aggregator/send_restlet_endpoint_job.rb index 9eacf99b480..70baf1a1d62 100644 --- a/app/jobs/integrations/aggregator/send_restlet_endpoint_job.rb +++ b/app/jobs/integrations/aggregator/send_restlet_endpoint_job.rb @@ -6,7 +6,7 @@ class SendRestletEndpointJob < ApplicationJob queue_as 'integrations' retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 - retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(integration:) result = Integrations::Aggregator::SendRestletEndpointService.call(integration:) diff --git a/app/jobs/integrations/aggregator/subscriptions/crm/create_customer_association_job.rb b/app/jobs/integrations/aggregator/subscriptions/crm/create_customer_association_job.rb index 4c19726bfef..cfc36a76771 100644 --- a/app/jobs/integrations/aggregator/subscriptions/crm/create_customer_association_job.rb +++ b/app/jobs/integrations/aggregator/subscriptions/crm/create_customer_association_job.rb @@ -8,7 +8,7 @@ class CreateCustomerAssociationJob < ApplicationJob queue_as 'integrations' retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10 - retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(subscription:) result = Integrations::Aggregator::Subscriptions::Crm::CreateCustomerAssociationService.call(subscription:) diff --git a/app/jobs/integrations/aggregator/subscriptions/crm/create_job.rb b/app/jobs/integrations/aggregator/subscriptions/crm/create_job.rb index 7e125d46108..0a2cf9ce63e 100644 --- a/app/jobs/integrations/aggregator/subscriptions/crm/create_job.rb +++ b/app/jobs/integrations/aggregator/subscriptions/crm/create_job.rb @@ -9,7 +9,7 @@ class CreateJob < ApplicationJob retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10 retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10 - retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(subscription:) result = Integrations::Aggregator::Subscriptions::Crm::CreateService.call(subscription:) diff --git a/app/jobs/integrations/aggregator/subscriptions/crm/update_job.rb b/app/jobs/integrations/aggregator/subscriptions/crm/update_job.rb index 6b28d5d975d..8860fd0d9e8 100644 --- a/app/jobs/integrations/aggregator/subscriptions/crm/update_job.rb +++ b/app/jobs/integrations/aggregator/subscriptions/crm/update_job.rb @@ -9,7 +9,7 @@ class UpdateJob < ApplicationJob retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10 retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10 - retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(subscription:) result = Integrations::Aggregator::Subscriptions::Crm::UpdateService.call(subscription:) diff --git a/app/jobs/integrations/hubspot/companies/deploy_properties_job.rb b/app/jobs/integrations/hubspot/companies/deploy_properties_job.rb index 80f7e3cd2b4..50b73adc6f5 100644 --- a/app/jobs/integrations/hubspot/companies/deploy_properties_job.rb +++ b/app/jobs/integrations/hubspot/companies/deploy_properties_job.rb @@ -7,7 +7,7 @@ class DeployPropertiesJob < ApplicationJob queue_as 'integrations' retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 - retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(integration:) result = Integrations::Hubspot::Companies::DeployPropertiesService.call(integration:) diff --git a/app/jobs/integrations/hubspot/contacts/deploy_properties_job.rb b/app/jobs/integrations/hubspot/contacts/deploy_properties_job.rb index 4cd7a78f2a3..c0c5350b747 100644 --- a/app/jobs/integrations/hubspot/contacts/deploy_properties_job.rb +++ b/app/jobs/integrations/hubspot/contacts/deploy_properties_job.rb @@ -7,7 +7,7 @@ class DeployPropertiesJob < ApplicationJob queue_as 'integrations' retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 - retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(integration:) result = Integrations::Hubspot::Contacts::DeployPropertiesService.call(integration:) diff --git a/app/jobs/integrations/hubspot/invoices/deploy_object_job.rb b/app/jobs/integrations/hubspot/invoices/deploy_object_job.rb index 8575b241868..a1d1570ddeb 100644 --- a/app/jobs/integrations/hubspot/invoices/deploy_object_job.rb +++ b/app/jobs/integrations/hubspot/invoices/deploy_object_job.rb @@ -7,7 +7,7 @@ class DeployObjectJob < ApplicationJob queue_as 'integrations' retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 - retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(integration:) result = Integrations::Hubspot::Invoices::DeployObjectService.call(integration:) diff --git a/app/jobs/integrations/hubspot/save_portal_id_job.rb b/app/jobs/integrations/hubspot/save_portal_id_job.rb index 17f515a1887..4452ee1ee63 100644 --- a/app/jobs/integrations/hubspot/save_portal_id_job.rb +++ b/app/jobs/integrations/hubspot/save_portal_id_job.rb @@ -6,6 +6,7 @@ class SavePortalIdJob < ApplicationJob queue_as 'integrations' retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 + retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(integration:) result = Integrations::Hubspot::SavePortalIdService.call(integration:) diff --git a/app/jobs/integrations/hubspot/subscriptions/deploy_object_job.rb b/app/jobs/integrations/hubspot/subscriptions/deploy_object_job.rb index 9e2d76ce9af..03ddde11e07 100644 --- a/app/jobs/integrations/hubspot/subscriptions/deploy_object_job.rb +++ b/app/jobs/integrations/hubspot/subscriptions/deploy_object_job.rb @@ -7,7 +7,7 @@ class DeployObjectJob < ApplicationJob queue_as 'integrations' retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3 - retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 10 + retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 100 def perform(integration:) result = Integrations::Hubspot::Subscriptions::DeployObjectService.call(integration:)