@@ -5,6 +5,7 @@ import { marqs } from "~/v3/marqs/index.server";
5
5
import { TaskRunStatus } from "@trigger.dev/database" ;
6
6
import { createExceptionPropertiesFromError , eventRepository } from "./eventRepository.server" ;
7
7
import { BaseService } from "./services/baseService.server" ;
8
+ import { FinalizeTaskRunService } from "./services/finalizeTaskRun.server" ;
8
9
9
10
const FAILABLE_TASK_RUN_STATUSES : TaskRunStatus [ ] = [ "EXECUTING" , "PENDING" , "WAITING_FOR_DEPLOY" ] ;
10
11
@@ -40,20 +41,13 @@ export class FailedTaskRunService extends BaseService {
40
41
// No more retries, we need to fail the task run
41
42
logger . debug ( "[FailedTaskRunService] Failing task run" , { taskRun, completion } ) ;
42
43
43
- /*
44
- "SYSTEM_FAILURE"
45
-
46
- Steps:
47
- 1. marqs ack
48
- 2. Completes the run span OTEL event
49
- 3. Updates the run to system failure
50
-
51
- Inputs:
52
- - taskRun: id, spanId
53
- - completion: error
54
- */
55
-
56
- await marqs ?. acknowledgeMessage ( taskRun . id ) ;
44
+ const finalizeService = new FinalizeTaskRunService ( ) ;
45
+ await finalizeService . call ( {
46
+ tx : this . _prisma ,
47
+ id : taskRun . id ,
48
+ status : "SYSTEM_FAILURE" ,
49
+ completedAt : new Date ( ) ,
50
+ } ) ;
57
51
58
52
// Now we need to "complete" the task run event/span
59
53
await eventRepository . completeEvent ( taskRun . spanId , {
@@ -71,15 +65,5 @@ export class FailedTaskRunService extends BaseService {
71
65
} ,
72
66
] ,
73
67
} ) ;
74
-
75
- await this . _prisma . taskRun . update ( {
76
- where : {
77
- id : taskRun . id ,
78
- } ,
79
- data : {
80
- status : "SYSTEM_FAILURE" ,
81
- completedAt : new Date ( ) ,
82
- } ,
83
- } ) ;
84
68
}
85
69
}
0 commit comments