Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

fix(portal): preserve trailing billing return check

pulse-triage[bot]ac721a264b56
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 7c99da74fe..aaaaaa9b62 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -3498,7 +3498,9 @@ plan changed in the Stripe billing portal applies without a click. It also
accepts a matching paid plan already applied by the background refresher
without requiring a second restart; an unchanged visit stays silent. A stale
panel is replaced only after the refreshed running plan is confirmed, never
-because the billing return URL says a change was made. Regression
+because the billing return URL says a change was made. When the return check
+finishes before the initial plan load, the panel may show that confirmed paid
+plan silently but must keep its second check for a later webhook. Regression
coverage:
`TestLoadConfig_ProviderHostedMSPPrefersRenewedLicense` in
`internal/cloudcp/config_test.go`,
diff --git a/internal/cloudcp/portal/dist/build_manifest.json b/internal/cloudcp/portal/dist/build_manifest.json
index 90c44f8d4e..58e6172e48 100644
--- a/internal/cloudcp/portal/dist/build_manifest.json
+++ b/internal/cloudcp/portal/dist/build_manifest.json
@@ -1,5 +1,5 @@
{
- "source_hash": "294e2ef873914caeb1132876df403b0ef2b101262f00cdaf34fb13d0b3d22c29",
+ "source_hash": "a630a1a29019df3a176613efe21ad63fd006ea2a531bdb1d4cadc2bbb50b2158",
"build_inputs": [
"package.json",
"tsconfig.json",
diff --git a/internal/cloudcp/portal/dist/portal_app.js b/internal/cloudcp/portal/dist/portal_app.js
index 68a7103de2..897d926212 100644
--- a/internal/cloudcp/portal/dist/portal_app.js
+++ b/internal/cloudcp/portal/dist/portal_app.js
@@ -2932,7 +2932,7 @@
if (billingReturn) {
if (!view.plan) {
acceptRunningPlan(plan, false);
- return true;
+ return false;
}
if (sameRunningPlan(view.plan, plan)) return false;
}
diff --git a/internal/cloudcp/portal/frontend/src/provider_plan.test.ts b/internal/cloudcp/portal/frontend/src/provider_plan.test.ts
index 45a59b6d31..aa5b3148a8 100644
--- a/internal/cloudcp/portal/frontend/src/provider_plan.test.ts
+++ b/internal/cloudcp/portal/frontend/src/provider_plan.test.ts
@@ -446,6 +446,33 @@ describe('installProviderPlan', () => {
expect(timers).toHaveLength(0);
});
+ it('keeps the second billing check when refresh finishes before the first plan load', async () => {
+ const oldPlan = evaluationPlan({
+ plan_version: 'msp_solo', evaluation: false, license_id: 'lic_old', workspace_limit: 3,
+ });
+ const newPlan = evaluationPlan({
+ plan_version: 'msp_starter', evaluation: false, license_id: 'lic_new', workspace_limit: 5,
+ });
+ let served = oldPlan;
+ api.fetchPlan = vi.fn().mockImplementation(() => Promise.resolve(served));
+ api.refreshLicense = vi.fn().mockImplementation(() => Promise.resolve({
+ status: 'active', changed: false, restart_scheduled: false,
+ plan_version: served.plan_version, license_id: served.license_id, expires_at: served.expires_at,
+ }));
+ const { controller } = install(providerBootstrap(), '?provider_msp_checkout=billing');
+ await flush();
+ expect(controller.view().plan).toEqual(oldPlan);
+ expect(controller.view().notice).toBe('');
+ expect(timers).toHaveLength(1);
+
+ served = newPlan;
+ timers.shift()!();
+ await flush();
+ expect(controller.view().plan).toEqual(newPlan);
+ expect(controller.view().notice).toBe('Your Starter plan is active.');
+ expect(timers).toHaveLength(0);
+ });
+
it('checks a Manage billing return only twice when nothing changed', async () => {
api.refreshLicense = vi.fn().mockResolvedValue({ status: 'active', changed: false });
const { controller } = install(providerBootstrap(), '?provider_msp_checkout=billing');
diff --git a/internal/cloudcp/portal/frontend/src/provider_plan.ts b/internal/cloudcp/portal/frontend/src/provider_plan.ts
index 47a19f735d..5664292c35 100644
--- a/internal/cloudcp/portal/frontend/src/provider_plan.ts
+++ b/internal/cloudcp/portal/frontend/src/provider_plan.ts
@@ -371,7 +371,9 @@ export function installProviderPlan(deps: ProviderPlanDeps): ProviderPlanControl
if (billingReturn) {
if (!view.plan) {
acceptRunningPlan(plan, false);
- return true;
+ // Without an earlier view there is no evidence of a change;
+ // keep the second check for a webhook trailing the redirect.
+ return false;
}
if (sameRunningPlan(view.plan, plan)) return false;
}