Skip to content

Commit 646aba1

Browse files
committed
fix(webapp): make entitlement cache invalidation best-effort
Cache removal in setPlan should not block or throw after the billing mutation has already committed. Switch from await to fire-and-forget with .catch(() => {}) so a Redis failure during cache invalidation cannot 500 the plan-change response. Per CodeRabbit review.
1 parent 58a87f4 commit 646aba1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

apps/webapp/app/services/platform.v3.server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ export async function setPlan(
373373
if (result.accepted) {
374374
// Invalidate billing cache since plan changed
375375
opts?.invalidateBillingCache?.(organization.id);
376-
await platformCache.entitlement.remove(organization.id);
376+
platformCache.entitlement.remove(organization.id).catch(() => {});
377377
return redirect(newProjectPath(organization, "You're on the Free plan."));
378378
} else {
379379
return redirectWithErrorMessage(
@@ -390,13 +390,13 @@ export async function setPlan(
390390
case "updated_subscription": {
391391
// Invalidate billing cache since subscription changed
392392
opts?.invalidateBillingCache?.(organization.id);
393-
await platformCache.entitlement.remove(organization.id);
393+
platformCache.entitlement.remove(organization.id).catch(() => {});
394394
return redirectWithSuccessMessage(callerPath, request, "Subscription updated successfully.");
395395
}
396396
case "canceled_subscription": {
397397
// Invalidate billing cache since subscription was canceled
398398
opts?.invalidateBillingCache?.(organization.id);
399-
await platformCache.entitlement.remove(organization.id);
399+
platformCache.entitlement.remove(organization.id).catch(() => {});
400400
return redirectWithSuccessMessage(callerPath, request, "Subscription canceled.");
401401
}
402402
}

0 commit comments

Comments
 (0)