Skip to content

fix: remove custom domains after plan expiry - #257

Merged
Innei merged 1 commit into
mainfrom
codex/cleanup-expired-custom-domains
Aug 7, 2026
Merged

fix: remove custom domains after plan expiry#257
Innei merged 1 commit into
mainfrom
codex/cleanup-expired-custom-domains

Conversation

@Innei

@Innei Innei commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • delete every Cloudflare Custom Hostname and local tenant-domain record after a paid plan is revoked
  • propagate cleanup failures so Creem can retry the expiration webhook
  • treat Cloudflare 404 responses as successful idempotent deletions
  • add regression coverage for the expiration hook, cleanup ordering, retry safety, and idempotent provider deletion

Why

Tenants lost custom-domain routing when their Pro entitlement expired, but the Cloudflare hostname and local domain record remained allocated. This leaked provider-side resources and retained stale bindings.

Validation

  • pnpm exec vitest run — 22 files, 79 tests passed
  • targeted ESLint — passed
  • pnpm run build for @afilmory/core — passed
  • standalone tsc --noEmit is currently blocked by the repository resolving TypeScript 5.9.3 while ignoreDeprecations is configured for 6.0

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
afilmory-demo Ready Ready Preview Aug 7, 2026 4:10pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
afilmory-docs Skipped Skipped Aug 7, 2026 4:10pm

@safedep

safedep Bot commented Aug 7, 2026

Copy link
Copy Markdown

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

View complete scan results →

This report is generated by SafeDep Github App

@Innei
Innei merged commit 1ea6c4b into main Aug 7, 2026
5 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cca58ebe94

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +566 to +568
if (shouldDeleteCustomDomains) {
try {
const deletedCount = await this.tenantDomainService.deleteDomainsForTenant(tenantId)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Verify the revocation is still current before deleting domains

When an expiration/cancellation webhook from an older subscription is delayed or retried after the tenant has purchased or reactivated a paid plan, this path still deletes every domain currently owned by the tenant because it validates neither the subscription identity nor the tenant's latest entitlement. Previously such an out-of-order event could temporarily set the plan to free, but a subsequent active webhook restored access to the retained binding; this change irreversibly removes the newly valid Cloudflare hostname and local record. Gate destructive cleanup on the revocation still representing the tenant's current subscription state.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant