Skip to content

Commit adacc88

Browse files
committed
Consolidated switch statement
1 parent bec58eb commit adacc88

File tree

1 file changed

+4
-60
lines changed

1 file changed

+4
-60
lines changed

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

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -49,37 +49,11 @@ export class TaskRunHeartbeatFailedService extends BaseService {
4949
const service = new FailedTaskRunService();
5050

5151
switch (taskRun.status) {
52-
case "PENDING": {
53-
const backInQueue = await marqs?.nackMessage(taskRun.id);
54-
55-
if (backInQueue) {
56-
logger.debug(
57-
`[TaskRunHeartbeatFailedService] ${taskRun.status} run is back in the queue run`,
58-
{
59-
taskRun,
60-
}
61-
);
62-
} else {
63-
logger.debug(
64-
`[TaskRunHeartbeatFailedService] ${taskRun.status} run not back in the queue, failing`,
65-
{ taskRun }
66-
);
67-
await service.call(taskRun.friendlyId, {
68-
ok: false,
69-
id: taskRun.friendlyId,
70-
retry: undefined,
71-
error: {
72-
type: "INTERNAL_ERROR",
73-
code: TaskRunErrorCodes.TASK_RUN_HEARTBEAT_TIMEOUT,
74-
message: "Did not receive a heartbeat from the worker in time",
75-
},
76-
});
77-
}
78-
79-
break;
80-
}
52+
case "PENDING":
8153
case "EXECUTING":
82-
case "RETRYING_AFTER_FAILURE": {
54+
case "RETRYING_AFTER_FAILURE":
55+
case "WAITING_TO_RESUME":
56+
case "PAUSED": {
8357
const backInQueue = await marqs?.nackMessage(taskRun.id);
8458

8559
if (backInQueue) {
@@ -119,36 +93,6 @@ export class TaskRunHeartbeatFailedService extends BaseService {
11993

12094
break;
12195
}
122-
case "WAITING_TO_RESUME":
123-
case "PAUSED": {
124-
const backInQueue = await marqs?.nackMessage(taskRun.id);
125-
126-
if (backInQueue) {
127-
logger.debug(
128-
`[TaskRunHeartbeatFailedService] ${taskRun.status} run is back in the queue run`,
129-
{
130-
taskRun,
131-
}
132-
);
133-
} else {
134-
logger.debug(
135-
`[TaskRunHeartbeatFailedService] ${taskRun.status} run not back in the queue, failing`,
136-
{ taskRun }
137-
);
138-
await service.call(taskRun.friendlyId, {
139-
ok: false,
140-
id: taskRun.friendlyId,
141-
retry: undefined,
142-
error: {
143-
type: "INTERNAL_ERROR",
144-
code: TaskRunErrorCodes.TASK_RUN_HEARTBEAT_TIMEOUT,
145-
message: "Did not receive a heartbeat from the worker in time",
146-
},
147-
});
148-
}
149-
150-
break;
151-
}
15296
case "SYSTEM_FAILURE":
15397
case "INTERRUPTED":
15498
case "CRASHED":

0 commit comments

Comments
 (0)