Skip to content

Commit b2e9108

Browse files
committed
fix(webapp): invalidate entitlement cache on plan changes
When setPlan transitions a customer's plan (free_connected, updated_subscription, canceled_subscription), invalidate the new entitlement cache alongside the existing billing cache invalidation. Without this, a downgrade or cancellation could leave hasAccess: true served from cache for up to 120s — meaning revoked access would linger. Per Devin's review on the swr cache PR.
1 parent 834a021 commit b2e9108

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +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);
376377
return redirect(newProjectPath(organization, "You're on the Free plan."));
377378
} else {
378379
return redirectWithErrorMessage(
@@ -389,11 +390,13 @@ export async function setPlan(
389390
case "updated_subscription": {
390391
// Invalidate billing cache since subscription changed
391392
opts?.invalidateBillingCache?.(organization.id);
393+
await platformCache.entitlement.remove(organization.id);
392394
return redirectWithSuccessMessage(callerPath, request, "Subscription updated successfully.");
393395
}
394396
case "canceled_subscription": {
395397
// Invalidate billing cache since subscription was canceled
396398
opts?.invalidateBillingCache?.(organization.id);
399+
await platformCache.entitlement.remove(organization.id);
397400
return redirectWithSuccessMessage(callerPath, request, "Subscription canceled.");
398401
}
399402
}

0 commit comments

Comments
 (0)