@@ -5,6 +5,7 @@ import { defaultMachine, getCurrentPlan } from "~/services/platform.v3.server";
55import { singleton } from "~/utils/singleton" ;
66import { allMachines } from "./machinePresets.server" ;
77import { meter , tracer } from "./tracer.server" ;
8+ import { logger } from "~/services/logger.server" ;
89
910export 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