Skip to content

Commit b7b3bb0

Browse files
committed
Don’t create an attempt if the run is already in a final status
1 parent 5c19ae5 commit b7b3bb0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

apps/webapp/app/v3/services/createTaskRunAttempt.server.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { BaseService, ServiceValidationError } from "./baseService.server";
1111
import { CrashTaskRunService } from "./crashTaskRun.server";
1212
import { ExpireEnqueuedRunService } from "./expireEnqueuedRun.server";
1313
import { findQueueInEnvironment } from "~/models/taskQueue.server";
14+
import { FINAL_RUN_STATUSES } from "../taskStatus";
1415

1516
export class CreateTaskRunAttemptService extends BaseService {
1617
public async call({
@@ -91,11 +92,17 @@ export class CreateTaskRunAttemptService extends BaseService {
9192

9293
span.setAttribute("taskRunId", taskRun.id);
9394
span.setAttribute("taskRunFriendlyId", taskRun.friendlyId);
95+
span.setAttribute("taskRunStatus", taskRun.status);
9496

9597
if (taskRun.status === "CANCELED") {
9698
throw new ServiceValidationError("Task run is cancelled", 400);
9799
}
98100

101+
// If the run is finalized, it's pointless to create another attempt
102+
if (FINAL_RUN_STATUSES.includes(taskRun.status)) {
103+
throw new ServiceValidationError("Task run is already finished", 400);
104+
}
105+
99106
const lockedBy = taskRun.lockedBy;
100107

101108
if (!lockedBy) {

0 commit comments

Comments
 (0)