From a1591e8b0cd8bb62815f1149b32cc5569bd9104d Mon Sep 17 00:00:00 2001 From: Jimmy Domagala-Tang Date: Fri, 13 Jun 2025 14:56:37 +0200 Subject: [PATCH] feat: log error for support to investigate, and return 200 to recurly to prevent retries (#26317) GitOrigin-RevId: 6f71fd4451e950a7bdbe1140a86a78bf8a04b039 --- .../src/Features/Subscription/SubscriptionController.js | 8 ++++++++ .../app/src/Features/Subscription/SubscriptionHandler.js | 2 +- .../app/src/Features/Subscription/SubscriptionUpdater.js | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/services/web/app/src/Features/Subscription/SubscriptionController.js b/services/web/app/src/Features/Subscription/SubscriptionController.js index 685e5e621b..3d70fd1d3f 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionController.js +++ b/services/web/app/src/Features/Subscription/SubscriptionController.js @@ -36,6 +36,7 @@ const PermissionsManager = require('../Authorization/PermissionsManager') const { sanitizeSessionUserForFrontEnd, } = require('../../infrastructure/FrontEndUser') +const { IndeterminateInvoiceError } = require('../Errors/Errors') /** * @import { SubscriptionChangeDescription } from '../../../../types/subscription/subscription-change-preview' @@ -622,6 +623,13 @@ function recurlyCallback(req, res, next) { eventData.transaction.subscription_id, lastSubscription, function (err) { + if (err instanceof IndeterminateInvoiceError) { + logger.warn( + { recurlySubscriptionId: err.info.recurlySubscriptionId }, + 'could not determine invoice to fail for subscription' + ) + return res.sendStatus(200) + } if (err) { return next(err) } diff --git a/services/web/app/src/Features/Subscription/SubscriptionHandler.js b/services/web/app/src/Features/Subscription/SubscriptionHandler.js index b83b52c852..104acd8783 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionHandler.js +++ b/services/web/app/src/Features/Subscription/SubscriptionHandler.js @@ -384,7 +384,7 @@ async function revertPlanChange( throw new IndeterminateInvoiceError( 'cant determine invoice to fail for plan revert', { - info: { recurlySubscriptionId }, + recurlySubscriptionId, } ) } diff --git a/services/web/app/src/Features/Subscription/SubscriptionUpdater.js b/services/web/app/src/Features/Subscription/SubscriptionUpdater.js index 70fa1a6403..9de194f262 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionUpdater.js +++ b/services/web/app/src/Features/Subscription/SubscriptionUpdater.js @@ -522,7 +522,7 @@ async function setRestorePoint(subscriptionId, planCode, addOns, consumed) { } if (consumed) { - update.$inc = { revertedDueToFailedPayment: 1 } + update.$inc = { timesRevertedDueToFailedPayment: 1 } } await Subscription.updateOne({ _id: subscriptionId }, update).exec()