Skip to content

Commit ed6e364

Browse files
committed
FailedTaskRunService uses FinalizeTaskRunService
1 parent 587b955 commit ed6e364

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

apps/webapp/app/v3/failedTaskRun.server.ts

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { marqs } from "~/v3/marqs/index.server";
55
import { TaskRunStatus } from "@trigger.dev/database";
66
import { createExceptionPropertiesFromError, eventRepository } from "./eventRepository.server";
77
import { BaseService } from "./services/baseService.server";
8+
import { FinalizeTaskRunService } from "./services/finalizeTaskRun.server";
89

910
const FAILABLE_TASK_RUN_STATUSES: TaskRunStatus[] = ["EXECUTING", "PENDING", "WAITING_FOR_DEPLOY"];
1011

@@ -40,20 +41,13 @@ export class FailedTaskRunService extends BaseService {
4041
// No more retries, we need to fail the task run
4142
logger.debug("[FailedTaskRunService] Failing task run", { taskRun, completion });
4243

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+
});
5751

5852
// Now we need to "complete" the task run event/span
5953
await eventRepository.completeEvent(taskRun.spanId, {
@@ -71,15 +65,5 @@ export class FailedTaskRunService extends BaseService {
7165
},
7266
],
7367
});
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-
});
8468
}
8569
}

0 commit comments

Comments
 (0)