Skip to content

Commit 57a3438

Browse files
committed
fix(engine): default to paid placement on billing errors
1 parent 4354977 commit 57a3438

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

apps/webapp/app/v3/runEngine.server.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { defaultMachine, getCurrentPlan } from "~/services/platform.v3.server";
55
import { singleton } from "~/utils/singleton";
66
import { allMachines } from "./machinePresets.server";
77
import { meter, tracer } from "./tracer.server";
8+
import { logger } from "~/services/logger.server";
89

910
export const engine = singleton("RunEngine", createRunEngine);
1011

@@ -120,23 +121,37 @@ function createRunEngine() {
120121
getCurrentPlan: async (orgId: string) => {
121122
const plan = await getCurrentPlan(orgId);
122123

124+
// This only happens when there's no billing service running or on errors
123125
if (!plan) {
126+
logger.warn("engine.getCurrentPlan: no plan", { orgId });
124127
return {
125-
isPaying: false,
126-
type: "free",
128+
isPaying: true,
129+
type: "paid", // default to paid
127130
};
128131
}
129132

133+
// This shouldn't happen
130134
if (!plan.v3Subscription) {
135+
logger.warn("engine.getCurrentPlan: no v3 subscription", { orgId });
131136
return {
132137
isPaying: false,
133138
type: "free",
134139
};
135140
}
136141

142+
// Neither should this
143+
if (!plan.v3Subscription.plan) {
144+
logger.warn("engine.getCurrentPlan: no v3 subscription plan", { orgId });
145+
return {
146+
isPaying: plan.v3Subscription.isPaying,
147+
type: "free",
148+
};
149+
}
150+
151+
// This is the normal case when the billing service is running
137152
return {
138153
isPaying: plan.v3Subscription.isPaying,
139-
type: plan.v3Subscription.plan?.type ?? "free",
154+
type: plan.v3Subscription.plan.type,
140155
};
141156
},
142157
},

0 commit comments

Comments
 (0)