From ccfe302363caa5015f56391138dbbf86305c9bc2 Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Thu, 3 Jul 2025 20:07:14 +0530 Subject: [PATCH] chore: add more logs for WebPush::TooManyRequests --- app/services/instagram/messenger/message_text.rb | 10 ++++++++++ app/services/notification/push_notification_service.rb | 2 ++ 2 files changed, 12 insertions(+) diff --git a/app/services/instagram/messenger/message_text.rb b/app/services/instagram/messenger/message_text.rb index ed544263e..f383bcdca 100644 --- a/app/services/instagram/messenger/message_text.rb +++ b/app/services/instagram/messenger/message_text.rb @@ -33,6 +33,16 @@ class Instagram::Messenger::MessageText < Instagram::BaseMessageText return end + # Handle error code 9010: No matching Instagram user + # This occurs when trying to fetch an Instagram user that doesn't exist or is not accessible + # We can safely ignore this error and return empty result + if error.message.include?('9010') + Rails.logger.warn("[Instagram User Not Found]: account_id #{@inbox.account_id} inbox_id #{@inbox.id}") + Rails.logger.warn("[Instagram User Not Found]: #{error.message}") + Rails.logger.warn("[Instagram User Not Found]: #{error}") + return + end + Rails.logger.warn("[FacebookUserFetchClientError]: account_id #{@inbox.account_id} inbox_id #{@inbox.id}") Rails.logger.warn("[FacebookUserFetchClientError]: #{error.message}") ChatwootExceptionTracker.new(error, account: @inbox.account).capture_exception diff --git a/app/services/notification/push_notification_service.rb b/app/services/notification/push_notification_service.rb index 9878107c1..901ccbc10 100644 --- a/app/services/notification/push_notification_service.rb +++ b/app/services/notification/push_notification_service.rb @@ -71,6 +71,8 @@ class Notification::PushNotificationService rescue WebPush::ExpiredSubscription, WebPush::InvalidSubscription, WebPush::Unauthorized => e Rails.logger.info "WebPush subscription expired: #{e.message}" subscription.destroy! + rescue WebPush::TooManyRequests => e + Rails.logger.warn "WebPush rate limited for #{user.email} on account #{notification.account.id}: #{e.message}" rescue Errno::ECONNRESET, Net::OpenTimeout, Net::ReadTimeout => e Rails.logger.error "WebPush operation error: #{e.message}" rescue StandardError => e