@@ -21,7 +21,6 @@ import { logger } from "~/services/logger.server";
2121import  {  newProjectPath ,  organizationBillingPath  }  from  "~/utils/pathBuilder" ; 
2222import  {  singleton  }  from  "~/utils/singleton" ; 
2323import  {  RedisCacheStore  }  from  "./unkey/redisCacheStore.server" ; 
24- import  {  engine  }  from  "~/v3/runEngine.server" ; 
2524import  {  existsSync ,  readFileSync  }  from  "node:fs" ; 
2625import  {  z  }  from  "zod" ; 
2726import  {  MachinePresetName  }  from  "@trigger.dev/core/v3" ; 
@@ -286,7 +285,8 @@ export async function setPlan(
286285  organization : {  id : string ;  slug : string  } , 
287286  request : Request , 
288287  callerPath : string , 
289-   plan : SetPlanBody 
288+   plan : SetPlanBody , 
289+   opts ?: {  invalidateBillingCache ?: ( orgId : string )  =>  void } 
290290)  { 
291291  if  ( ! client )  { 
292292    throw  redirectWithErrorMessage ( callerPath ,  request ,  "Error setting plan" ) ; 
@@ -310,7 +310,7 @@ export async function setPlan(
310310      case  "free_connected" : { 
311311        if  ( result . accepted )  { 
312312          // Invalidate billing cache since plan changed 
313-           engine . invalidateBillingCache ( organization . id ) ; 
313+           opts ? .invalidateBillingCache ?. ( organization . id ) ; 
314314          return  redirect ( newProjectPath ( organization ,  "You're on the Free plan." ) ) ; 
315315        }  else  { 
316316          return  redirectWithErrorMessage ( 
@@ -325,7 +325,7 @@ export async function setPlan(
325325      } 
326326      case  "updated_subscription" : { 
327327        // Invalidate billing cache since subscription changed 
328-         engine . invalidateBillingCache ( organization . id ) ; 
328+         opts ? .invalidateBillingCache ?. ( organization . id ) ; 
329329        return  redirectWithSuccessMessage ( 
330330          callerPath , 
331331          request , 
@@ -334,7 +334,7 @@ export async function setPlan(
334334      } 
335335      case  "canceled_subscription" : { 
336336        // Invalidate billing cache since subscription was canceled 
337-         engine . invalidateBillingCache ( organization . id ) ; 
337+         opts ? .invalidateBillingCache ?. ( organization . id ) ; 
338338        return  redirectWithSuccessMessage ( callerPath ,  request ,  "Subscription canceled." ) ; 
339339      } 
340340    } 
0 commit comments