File tree Expand file tree Collapse file tree 3 files changed +26
-18
lines changed
packages/core/src/v3/apiClient Expand file tree Collapse file tree 3 files changed +26
-18
lines changed Original file line number Diff line number Diff line change 11import { RunEngineVersion , type RuntimeEnvironmentType } from "@trigger.dev/database" ;
2+ import { $replica } from "~/db.server" ;
23import {
3- findCurrentWorkerDeploymentWithoutTasks ,
44 findCurrentWorkerFromEnvironment ,
5+ getCurrentWorkerDeploymentEngineVersion ,
56} from "./models/workerDeployment.server" ;
6- import { $replica } from "~/db.server" ;
77
88type Environment = {
99 id : string ;
@@ -65,10 +65,12 @@ export async function determineEngineVersion({
6565 }
6666
6767 // Deployed: use the latest deployed BackgroundWorker
68- const currentDeployment = await findCurrentWorkerDeploymentWithoutTasks ( environment . id ) ;
69- if ( currentDeployment ?. type === "V1" ) {
70- return "V1" ;
68+ const currentDeploymentEngineVersion = await getCurrentWorkerDeploymentEngineVersion (
69+ environment . id
70+ ) ;
71+ if ( currentDeploymentEngineVersion ) {
72+ return currentDeploymentEngineVersion ;
7173 }
7274
73- return "V2" ;
75+ return environment . project . engine ;
7476}
Original file line number Diff line number Diff line change 11import type { Prettify } from "@trigger.dev/core" ;
2- import { BackgroundWorker , WorkerDeployment } from "@trigger.dev/database" ;
2+ import { BackgroundWorker , RunEngineVersion , WorkerDeployment } from "@trigger.dev/database" ;
33import {
44 CURRENT_DEPLOYMENT_LABEL ,
55 CURRENT_UNMANAGED_DEPLOYMENT_LABEL ,
@@ -91,23 +91,29 @@ export async function findCurrentWorkerDeployment(
9191 return promotion ?. deployment ;
9292}
9393
94- export async function findCurrentWorkerDeploymentWithoutTasks (
94+ export async function getCurrentWorkerDeploymentEngineVersion (
9595 environmentId : string ,
9696 label = CURRENT_DEPLOYMENT_LABEL
97- ) : Promise < WorkerDeployment | undefined > {
98- const promotion = await prisma . workerDeploymentPromotion . findUnique ( {
97+ ) : Promise < RunEngineVersion | undefined > {
98+ const promotion = await prisma . workerDeploymentPromotion . findFirst ( {
9999 where : {
100- environmentId_label : {
101- environmentId,
102- label,
103- } ,
100+ environmentId,
101+ label,
104102 } ,
105- include : {
106- deployment : true ,
103+ select : {
104+ deployment : {
105+ select : {
106+ type : true ,
107+ } ,
108+ } ,
107109 } ,
108110 } ) ;
109111
110- return promotion ?. deployment ;
112+ if ( typeof promotion ?. deployment . type === "string" ) {
113+ return promotion . deployment . type === "V1" ? "V1" : "V2" ;
114+ }
115+
116+ return undefined ;
111117}
112118
113119export async function findCurrentUnmanagedWorkerDeployment (
Original file line number Diff line number Diff line change @@ -973,7 +973,7 @@ export class ApiClient {
973973 "Content-Type" : "application/json" ,
974974 Authorization : `Bearer ${ this . accessToken } ` ,
975975 "trigger-version" : VERSION ,
976- "x-trigger-engine-version" : taskContext . worker ?. engine ?? "V2" ,
976+ "x-trigger-engine-version" : "V2" ,
977977 ...Object . entries ( additionalHeaders ?? { } ) . reduce (
978978 ( acc , [ key , value ] ) => {
979979 if ( value !== undefined ) {
You can’t perform that action at this time.
0 commit comments