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 1
1
import { RunEngineVersion , type RuntimeEnvironmentType } from "@trigger.dev/database" ;
2
+ import { $replica } from "~/db.server" ;
2
3
import {
3
- findCurrentWorkerDeploymentWithoutTasks ,
4
4
findCurrentWorkerFromEnvironment ,
5
+ getCurrentWorkerDeploymentEngineVersion ,
5
6
} from "./models/workerDeployment.server" ;
6
- import { $replica } from "~/db.server" ;
7
7
8
8
type Environment = {
9
9
id : string ;
@@ -65,10 +65,12 @@ export async function determineEngineVersion({
65
65
}
66
66
67
67
// 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 ;
71
73
}
72
74
73
- return "V2" ;
75
+ return environment . project . engine ;
74
76
}
Original file line number Diff line number Diff line change 1
1
import type { Prettify } from "@trigger.dev/core" ;
2
- import { BackgroundWorker , WorkerDeployment } from "@trigger.dev/database" ;
2
+ import { BackgroundWorker , RunEngineVersion , WorkerDeployment } from "@trigger.dev/database" ;
3
3
import {
4
4
CURRENT_DEPLOYMENT_LABEL ,
5
5
CURRENT_UNMANAGED_DEPLOYMENT_LABEL ,
@@ -91,23 +91,29 @@ export async function findCurrentWorkerDeployment(
91
91
return promotion ?. deployment ;
92
92
}
93
93
94
- export async function findCurrentWorkerDeploymentWithoutTasks (
94
+ export async function getCurrentWorkerDeploymentEngineVersion (
95
95
environmentId : string ,
96
96
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 ( {
99
99
where : {
100
- environmentId_label : {
101
- environmentId,
102
- label,
103
- } ,
100
+ environmentId,
101
+ label,
104
102
} ,
105
- include : {
106
- deployment : true ,
103
+ select : {
104
+ deployment : {
105
+ select : {
106
+ type : true ,
107
+ } ,
108
+ } ,
107
109
} ,
108
110
} ) ;
109
111
110
- return promotion ?. deployment ;
112
+ if ( typeof promotion ?. deployment . type === "string" ) {
113
+ return promotion . deployment . type === "V1" ? "V1" : "V2" ;
114
+ }
115
+
116
+ return undefined ;
111
117
}
112
118
113
119
export async function findCurrentUnmanagedWorkerDeployment (
Original file line number Diff line number Diff line change @@ -973,7 +973,7 @@ export class ApiClient {
973
973
"Content-Type" : "application/json" ,
974
974
Authorization : `Bearer ${ this . accessToken } ` ,
975
975
"trigger-version" : VERSION ,
976
- "x-trigger-engine-version" : taskContext . worker ?. engine ?? "V2" ,
976
+ "x-trigger-engine-version" : "V2" ,
977
977
...Object . entries ( additionalHeaders ?? { } ) . reduce (
978
978
( acc , [ key , value ] ) => {
979
979
if ( value !== undefined ) {
You can’t perform that action at this time.
0 commit comments