Skip to content

Commit 19aa804

Browse files
committed
Merge remote-tracking branch 'origin/main' into full-width-tables
2 parents 87c7eb9 + 332854b commit 19aa804

File tree

118 files changed

+4043
-631
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+4043
-631
lines changed

.changeset/brave-forks-compare.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

.changeset/brown-laws-rest.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/cuddly-pugs-begin.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/eight-turtles-itch.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

.changeset/good-ligers-sit.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

apps/kubernetes-provider/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ provider.listen();
661661

662662
const taskMonitor = new TaskMonitor({
663663
runtimeEnv: RUNTIME_ENV,
664+
namespace: KUBERNETES_NAMESPACE,
664665
onIndexFailure: async (deploymentId, details) => {
665666
logger.log("Indexing failed", { deploymentId, details });
666667

apps/kubernetes-provider/src/taskMonitor.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ export class TaskMonitor {
160160

161161
let reason = rawReason || "Unknown error";
162162
let logs = rawLogs || "";
163-
let overrideCompletion = false;
163+
164+
/** This will only override existing task errors. It will not crash the run. */
165+
let onlyOverrideExistingError = exitCode === EXIT_CODE_CHILD_NONZERO;
166+
164167
let errorCode: TaskRunInternalError["code"] = TaskRunErrorCodes.POD_UNKNOWN_ERROR;
165168

166169
switch (rawReason) {
@@ -185,10 +188,8 @@ export class TaskMonitor {
185188
}
186189
break;
187190
case "OOMKilled":
188-
overrideCompletion = true;
189-
reason = `${
190-
exitCode === EXIT_CODE_CHILD_NONZERO ? "Child process" : "Parent process"
191-
} ran out of memory! Try choosing a machine preset with more memory for this task.`;
191+
reason =
192+
"[TaskMonitor] Your task ran out of memory. Try increasing the machine specs. If this doesn't fix it there might be a memory leak.";
192193
errorCode = TaskRunErrorCodes.TASK_PROCESS_OOM_KILLED;
193194
break;
194195
default:
@@ -199,7 +200,7 @@ export class TaskMonitor {
199200
exitCode,
200201
reason,
201202
logs,
202-
overrideCompletion,
203+
overrideCompletion: onlyOverrideExistingError,
203204
errorCode,
204205
} satisfies FailureDetails;
205206

apps/webapp/app/components/runs/v3/SpanEvents.tsx

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import { EnvelopeIcon } from "@heroicons/react/20/solid";
12
import {
23
exceptionEventEnhancer,
34
isExceptionSpanEvent,
45
type ExceptionEventProperties,
56
type SpanEvent as OtelSpanEvent,
67
} from "@trigger.dev/core/v3";
78
import { CodeBlock } from "~/components/code/CodeBlock";
9+
import { Feedback } from "~/components/Feedback";
10+
import { Button } from "~/components/primitives/Buttons";
811
import { Callout } from "~/components/primitives/Callout";
912
import { DateTimeAccurate } from "~/components/primitives/DateTime";
1013
import { Header2, Header3 } from "~/components/primitives/Headers";
@@ -75,11 +78,26 @@ export function SpanEventError({
7578
titleClassName="text-rose-500"
7679
/>
7780
{enhancedException.message && <Callout variant="error">{enhancedException.message}</Callout>}
78-
{enhancedException.link && (
79-
<Callout variant="docs" to={enhancedException.link.href}>
80-
{enhancedException.link.name}
81-
</Callout>
82-
)}
81+
{enhancedException.link &&
82+
(enhancedException.link.magic === "CONTACT_FORM" ? (
83+
<Feedback
84+
button={
85+
<Button
86+
variant="tertiary/medium"
87+
LeadingIcon={EnvelopeIcon}
88+
leadingIconClassName="text-blue-400"
89+
fullWidth
90+
textAlignLeft
91+
>
92+
{enhancedException.link.name}
93+
</Button>
94+
}
95+
/>
96+
) : (
97+
<Callout variant="docs" to={enhancedException.link.href}>
98+
{enhancedException.link.name}
99+
</Callout>
100+
))}
83101
{enhancedException.stacktrace && (
84102
<CodeBlock
85103
showCopyButton={false}

apps/webapp/app/env.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const EnvironmentSchema = z.object({
3131
REMIX_APP_PORT: z.string().optional(),
3232
LOGIN_ORIGIN: z.string().default("http://localhost:3030"),
3333
APP_ORIGIN: z.string().default("http://localhost:3030"),
34+
API_ORIGIN: z.string().optional(),
3435
ELECTRIC_ORIGIN: z.string().default("http://localhost:3060"),
3536
APP_ENV: z.string().default(process.env.NODE_ENV),
3637
SERVICE_NAME: z.string().default("trigger.dev webapp"),

apps/webapp/app/models/taskRun.server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {
33
TaskRunFailedExecutionResult,
44
TaskRunSuccessfulExecutionResult,
55
} from "@trigger.dev/core/v3";
6-
import { TaskRunError } from "@trigger.dev/core/v3";
6+
import { TaskRunError, TaskRunErrorCodes } from "@trigger.dev/core/v3";
77

88
import type {
99
TaskRun,
@@ -62,7 +62,7 @@ export function executionResultForTaskRun(
6262
id: taskRun.friendlyId,
6363
error: {
6464
type: "INTERNAL_ERROR",
65-
code: "TASK_RUN_CANCELLED",
65+
code: TaskRunErrorCodes.TASK_RUN_CANCELLED,
6666
},
6767
} satisfies TaskRunFailedExecutionResult;
6868
}
@@ -94,7 +94,7 @@ export function executionResultForTaskRun(
9494
id: taskRun.friendlyId,
9595
error: {
9696
type: "INTERNAL_ERROR",
97-
code: "CONFIGURED_INCORRECTLY",
97+
code: TaskRunErrorCodes.CONFIGURED_INCORRECTLY,
9898
},
9999
} satisfies TaskRunFailedExecutionResult;
100100
}

apps/webapp/app/v3/environmentVariables/environmentVariablesRepository.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ async function resolveBuiltInProdVariables(runtimeEnvironment: RuntimeEnvironmen
732732
},
733733
{
734734
key: "TRIGGER_API_URL",
735-
value: env.APP_ORIGIN,
735+
value: env.API_ORIGIN ?? env.APP_ORIGIN,
736736
},
737737
{
738738
key: "TRIGGER_RUNTIME_WAIT_THRESHOLD_IN_MS",

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

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,15 @@ export class FailedTaskRunRetryHelper extends BaseService {
112112

113113
logger.debug("[FailedTaskRunRetryHelper] Completing attempt", { taskRun, completion });
114114

115-
const executionRetry =
116-
completion.retry ??
117-
(await FailedTaskRunRetryHelper.getExecutionRetry({
118-
run: taskRun,
119-
execution: retriableExecution,
120-
}));
121-
122-
const completeAttempt = new CompleteAttemptService(this._prisma);
123-
const completeResult = await completeAttempt.call({
124-
completion: {
125-
...completion,
126-
retry: executionRetry,
127-
},
128-
execution: retriableExecution,
115+
const completeAttempt = new CompleteAttemptService({
116+
prisma: this._prisma,
129117
isSystemFailure: !isCrash,
130118
isCrash,
131119
});
120+
const completeResult = await completeAttempt.call({
121+
completion,
122+
execution: retriableExecution,
123+
});
132124

133125
return completeResult;
134126
}
@@ -280,6 +272,5 @@ export class FailedTaskRunRetryHelper extends BaseService {
280272
}
281273
}
282274

283-
// TODO: update this to the correct version
284-
static DEFAULT_RETRY_CONFIG_SINCE_VERSION = "3.0.14";
275+
static DEFAULT_RETRY_CONFIG_SINCE_VERSION = "3.1.0";
285276
}

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

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { Redis } from "ioredis";
2424
import { createAdapter } from "@socket.io/redis-adapter";
2525
import { CrashTaskRunService } from "./services/crashTaskRun.server";
2626
import { CreateTaskRunAttemptService } from "./services/createTaskRunAttempt.server";
27+
import { UpdateFatalRunErrorService } from "./services/updateFatalRunError.server";
2728

2829
export const socketIo = singleton("socketIo", initalizeIoServer);
2930

@@ -103,13 +104,16 @@ function createCoordinatorNamespace(io: Server) {
103104
);
104105

105106
if (!payload) {
106-
logger.error("Failed to retrieve lazy attempt payload", message);
107-
return { success: false, reason: "Failed to retrieve payload" };
107+
logger.error(
108+
"READY_FOR_LAZY_ATTEMPT: Failed to retrieve lazy attempt payload",
109+
message
110+
);
111+
return { success: false, reason: "READY_FOR_LAZY_ATTEMPT: Failed to retrieve payload" };
108112
}
109113

110114
return { success: true, lazyPayload: payload };
111115
} catch (error) {
112-
logger.error("Error while creating lazy attempt", {
116+
logger.error("READY_FOR_LAZY_ATTEMPT: Error while creating lazy attempt", {
113117
runId: message.runId,
114118
envId: message.envId,
115119
totalCompletions: message.totalCompletions,
@@ -123,12 +127,13 @@ function createCoordinatorNamespace(io: Server) {
123127
await resumeAttempt.call(message);
124128
},
125129
TASK_RUN_COMPLETED: async (message) => {
126-
const completeAttempt = new CompleteAttemptService();
130+
const completeAttempt = new CompleteAttemptService({
131+
supportsRetryCheckpoints: message.version === "v1",
132+
});
127133
await completeAttempt.call({
128134
completion: message.completion,
129135
execution: message.execution,
130136
checkpoint: message.checkpoint,
131-
supportsRetryCheckpoints: message.version === "v1",
132137
});
133138
},
134139
TASK_RUN_FAILED_TO_RUN: async (message) => {
@@ -205,13 +210,19 @@ function createCoordinatorNamespace(io: Server) {
205210
});
206211

207212
if (!payload) {
208-
logger.error("Failed to retrieve payload after attempt creation", message);
209-
return { success: false, reason: "Failed to retrieve payload" };
213+
logger.error(
214+
"CREATE_TASK_RUN_ATTEMPT: Failed to retrieve payload after attempt creation",
215+
message
216+
);
217+
return {
218+
success: false,
219+
reason: "CREATE_TASK_RUN_ATTEMPT: Failed to retrieve payload",
220+
};
210221
}
211222

212223
return { success: true, executionPayload: payload };
213224
} catch (error) {
214-
logger.error("Error while creating attempt", {
225+
logger.error("CREATE_TASK_RUN_ATTEMPT: Error while creating attempt", {
215226
...message,
216227
error,
217228
});
@@ -301,11 +312,13 @@ function createProviderNamespace(io: Server) {
301312
handlers: {
302313
WORKER_CRASHED: async (message) => {
303314
try {
304-
const service = new CrashTaskRunService();
305-
306-
await service.call(message.runId, {
307-
...message,
308-
});
315+
if (message.overrideCompletion) {
316+
const updateErrorService = new UpdateFatalRunErrorService();
317+
await updateErrorService.call(message.runId, { ...message });
318+
} else {
319+
const crashRunService = new CrashTaskRunService();
320+
await crashRunService.call(message.runId, { ...message });
321+
}
309322
} catch (error) {
310323
logger.error("Error while handling crashed worker", { error });
311324
}

apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
ProdTaskRunExecution,
55
ProdTaskRunExecutionPayload,
66
TaskRunError,
7+
TaskRunErrorCodes,
78
TaskRunExecution,
89
TaskRunExecutionLazyAttemptPayload,
910
TaskRunExecutionResult,
@@ -519,6 +520,11 @@ export class SharedQueueConsumer {
519520
taskRun: lockedTaskRun.id,
520521
});
521522

523+
const service = new CrashTaskRunService();
524+
await service.call(lockedTaskRun.id, {
525+
errorCode: TaskRunErrorCodes.OUTDATED_SDK_VERSION,
526+
});
527+
522528
await this.#ackAndDoMoreWork(message.messageId);
523529
return;
524530
}
@@ -1080,18 +1086,21 @@ class SharedQueueTasks {
10801086
});
10811087

10821088
if (!attempt) {
1083-
logger.error("No attempt found", { id });
1089+
logger.error("getExecutionPayloadFromAttempt: No attempt found", { id });
10841090
return;
10851091
}
10861092

10871093
if (!skipStatusChecks) {
10881094
switch (attempt.status) {
10891095
case "CANCELED":
10901096
case "EXECUTING": {
1091-
logger.error("Invalid attempt status for execution payload retrieval", {
1092-
attemptId: id,
1093-
status: attempt.status,
1094-
});
1097+
logger.error(
1098+
"getExecutionPayloadFromAttempt: Invalid attempt status for execution payload retrieval",
1099+
{
1100+
attemptId: id,
1101+
status: attempt.status,
1102+
}
1103+
);
10951104
return;
10961105
}
10971106
}
@@ -1100,19 +1109,22 @@ class SharedQueueTasks {
11001109
case "CANCELED":
11011110
case "EXECUTING":
11021111
case "INTERRUPTED": {
1103-
logger.error("Invalid run status for execution payload retrieval", {
1104-
attemptId: id,
1105-
runId: attempt.taskRunId,
1106-
status: attempt.taskRun.status,
1107-
});
1112+
logger.error(
1113+
"getExecutionPayloadFromAttempt: Invalid run status for execution payload retrieval",
1114+
{
1115+
attemptId: id,
1116+
runId: attempt.taskRunId,
1117+
status: attempt.taskRun.status,
1118+
}
1119+
);
11081120
return;
11091121
}
11101122
}
11111123
}
11121124

11131125
if (setToExecuting) {
11141126
if (isFinalAttemptStatus(attempt.status) || isFinalRunStatus(attempt.taskRun.status)) {
1115-
logger.error("Status already in final state", {
1127+
logger.error("getExecutionPayloadFromAttempt: Status already in final state", {
11161128
attempt: {
11171129
id: attempt.id,
11181130
status: attempt.status,
@@ -1303,7 +1315,7 @@ class SharedQueueTasks {
13031315
},
13041316
});
13051317

1306-
logger.debug("Getting lazy attempt payload for run", {
1318+
logger.debug("getLazyAttemptPayload: Getting lazy attempt payload for run", {
13071319
run,
13081320
attemptCount,
13091321
});

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { BaseService } from "./services/baseService.server";
77
import { PrismaClientOrTransaction } from "~/db.server";
88
import { workerQueue } from "~/services/worker.server";
99
import { socketIo } from "./handleSocketIo.server";
10+
import { TaskRunErrorCodes } from "@trigger.dev/core/v3";
1011

1112
export class RequeueTaskRunService extends BaseService {
1213
public async call(runId: string) {
@@ -59,7 +60,7 @@ export class RequeueTaskRunService extends BaseService {
5960
retry: undefined,
6061
error: {
6162
type: "INTERNAL_ERROR",
62-
code: "TASK_RUN_HEARTBEAT_TIMEOUT",
63+
code: TaskRunErrorCodes.TASK_RUN_HEARTBEAT_TIMEOUT,
6364
message: "Did not receive a heartbeat from the worker in time",
6465
},
6566
});

0 commit comments

Comments
 (0)