Skip to content

Commit bcc330d

Browse files
committed
Merge remote-tracking branch 'origin/main' into docs/vercel-sync-env-vars
2 parents 4224813 + 6313db6 commit bcc330d

File tree

115 files changed

+4607
-1052
lines changed

Some content is hidden

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

115 files changed

+4607
-1052
lines changed

.changeset/brave-forks-compare.md

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

.changeset/good-ligers-sit.md

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

.github/workflows/unit-tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ jobs:
3838
SESSION_SECRET: "secret"
3939
MAGIC_LINK_SECRET: "secret"
4040
ENCRYPTION_KEY: "secret"
41-
41+
42+
- name: 🧪 Run Package Unit Tests
43+
run: pnpm run test --filter "@trigger.dev/*"
4244

4345
- name: 🧪 Run Internal Unit Tests
4446
run: pnpm run test --filter "@internal/*"

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/proxy/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"private": true,
55
"scripts": {
66
"deploy": "wrangler deploy",
7-
"dev": "wrangler dev"
7+
"dev": "wrangler dev",
8+
"dry-run:staging": "wrangler deploy --dry-run --outdir=dist --env staging"
89
},
910
"devDependencies": {
1011
"@cloudflare/workers-types": "^4.20240512.0",

apps/proxy/src/index.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ export interface Env {
1717

1818
export default {
1919
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
20-
if (!env.REWRITE_HOSTNAME) throw new Error("Missing REWRITE_HOSTNAME");
21-
console.log("url", request.url);
22-
2320
if (!queueingIsEnabled(env)) {
2421
console.log("Missing AWS credentials. Passing through to the origin.");
25-
return redirectToOrigin(request, env);
22+
return fetch(request);
2623
}
2724

2825
const url = new URL(request.url);
@@ -42,25 +39,10 @@ export default {
4239
}
4340

4441
//the same request but with the hostname (and port) changed
45-
return redirectToOrigin(request, env);
42+
return fetch(request);
4643
},
4744
};
4845

49-
function redirectToOrigin(request: Request, env: Env) {
50-
const newUrl = new URL(request.url);
51-
newUrl.hostname = env.REWRITE_HOSTNAME;
52-
newUrl.port = env.REWRITE_PORT || newUrl.port;
53-
54-
const requestInit: RequestInit = {
55-
method: request.method,
56-
headers: request.headers,
57-
body: request.body,
58-
};
59-
60-
console.log("rewritten url", newUrl.toString());
61-
return fetch(newUrl.toString(), requestInit);
62-
}
63-
6446
function queueingIsEnabled(env: Env) {
6547
return (
6648
env.AWS_SQS_ACCESS_KEY_ID &&

apps/webapp/app/components/ErrorDisplay.tsx

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import { HomeIcon } from "@heroicons/react/20/solid";
12
import { isRouteErrorResponse, useRouteError } from "@remix-run/react";
2-
import { LinkButton } from "./primitives/Buttons";
3-
import { Header1, Header3 } from "./primitives/Headers";
3+
import { motion } from "framer-motion";
44
import { friendlyErrorDisplay } from "~/utils/httpErrors";
5+
import { LinkButton } from "./primitives/Buttons";
6+
import { Header1 } from "./primitives/Headers";
7+
import { Paragraph } from "./primitives/Paragraph";
58

69
type ErrorDisplayOptions = {
710
button?: {
@@ -39,12 +42,32 @@ type DisplayOptionsProps = {
3942

4043
export function ErrorDisplay({ title, message, button }: DisplayOptionsProps) {
4144
return (
42-
<div className="p-4">
43-
<Header1 className="mb-4 border-b border-charcoal-800 pb-4">{title}</Header1>
44-
{message && <Header3>{message}</Header3>}
45-
<LinkButton to={button ? button.to : "/"} variant="primary/medium" className="mt-8">
46-
{button ? button.title : "Home"}
47-
</LinkButton>
45+
<div className="relative flex min-h-screen flex-col items-center justify-center bg-[#16181C]">
46+
<div className="z-10 mt-[30vh] flex flex-col items-center gap-8">
47+
<Header1>{title}</Header1>
48+
{message && <Paragraph>{message}</Paragraph>}
49+
<LinkButton
50+
to={button ? button.to : "/"}
51+
shortcut={{ modifiers: ["meta"], key: "g" }}
52+
variant="primary/medium"
53+
LeadingIcon={HomeIcon}
54+
>
55+
{button ? button.title : "Go to homepage"}
56+
</LinkButton>
57+
</div>
58+
<div className="pointer-events-none absolute bottom-4 right-4 z-10 h-[70px] w-[200px] bg-[rgb(24,26,30)]" />
59+
<motion.div
60+
className="pointer-events-none absolute inset-0 overflow-hidden"
61+
initial={{ opacity: 0 }}
62+
animate={{ opacity: 1 }}
63+
transition={{ delay: 0.5, duration: 2, ease: "easeOut" }}
64+
>
65+
<iframe
66+
src="https://my.spline.design/untitled-a6f70b5ebc46bdb2dcc0f21d5397e8ac/"
67+
className="pointer-events-none absolute inset-0 h-full w-full object-cover"
68+
style={{ border: "none" }}
69+
/>
70+
</motion.div>
4871
</div>
4972
);
5073
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
} from "~/utils/pathBuilder";
4141
import { TraceSpan } from "~/utils/taskEvent";
4242
import { SpanLink } from "~/v3/eventRepository.server";
43-
import { isFinalRunStatus } from "~/v3/taskStatus";
43+
import { isFailedRunStatus, isFinalRunStatus } from "~/v3/taskStatus";
4444
import { RunTimelineEvent, RunTimelineLine } from "./InspectorTimeline";
4545
import { RunTag } from "./RunTag";
4646
import { TaskRunStatusCombo } from "./TaskRunStatus";
@@ -479,6 +479,7 @@ function RunTimeline({ run }: { run: RawRun }) {
479479
const updatedAt = new Date(run.updatedAt);
480480

481481
const isFinished = isFinalRunStatus(run.status);
482+
const isError = isFailedRunStatus(run.status);
482483

483484
return (
484485
<div className="min-w-fit max-w-80">
@@ -535,7 +536,7 @@ function RunTimeline({ run }: { run: RawRun }) {
535536
<RunTimelineEvent
536537
title="Finished"
537538
subtitle={<DateTimeAccurate date={updatedAt} />}
538-
state="complete"
539+
state={isError ? "error" : "complete"}
539540
/>
540541
</>
541542
) : (

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/presenters/v3/SpanPresenter.server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
import { RUNNING_STATUSES } from "~/components/runs/v3/TaskRunStatus";
88
import { eventRepository } from "~/v3/eventRepository.server";
99
import { machinePresetFromName } from "~/v3/machinePresets.server";
10-
import { FINAL_ATTEMPT_STATUSES, isFinalRunStatus } from "~/v3/taskStatus";
10+
import { FINAL_ATTEMPT_STATUSES, isFailedRunStatus, isFinalRunStatus } from "~/v3/taskStatus";
1111
import { BasePresenter } from "./basePresenter.server";
1212
import { getMaxDuration } from "~/v3/utils/maxDuration";
1313

@@ -294,6 +294,7 @@ export class SpanPresenter extends BasePresenter {
294294
usageDurationMs: run.usageDurationMs,
295295
isFinished,
296296
isRunning: RUNNING_STATUSES.includes(run.status),
297+
isError: isFailedRunStatus(run.status),
297298
payload,
298299
payloadType: run.payloadType,
299300
output,

apps/webapp/app/routes/_app.orgs.$organizationSlug/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,6 @@ export function ErrorBoundary() {
127127
return org ? (
128128
<RouteErrorDisplay button={{ title: org.title, to: organizationPath(org) }} />
129129
) : (
130-
<RouteErrorDisplay button={{ title: "Home", to: "/" }} />
130+
<RouteErrorDisplay button={{ title: "Go to homepage", to: "/" }} />
131131
);
132132
}

apps/webapp/app/routes/api.v1.runs.$runParam.attempts.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ export async function action({ request, params }: ActionFunctionArgs) {
2929
const service = new CreateTaskRunAttemptService();
3030

3131
try {
32-
const { execution } = await service.call(runParam, authenticationResult.environment);
32+
const { execution } = await service.call({
33+
runId: runParam,
34+
authenticatedEnv: authenticationResult.environment,
35+
});
3336

3437
return json(execution, { status: 200 });
3538
} catch (error) {

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.schedules.new/route.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import { CronPattern, UpsertSchedule } from "~/v3/schedules";
4444
import { UpsertTaskScheduleService } from "~/v3/services/upsertTaskSchedule.server";
4545
import { AIGeneratedCronField } from "../resources.orgs.$organizationSlug.projects.$projectParam.schedules.new.natural-language";
4646
import { TimezoneList } from "~/components/scheduled/timezones";
47+
import { logger } from "~/services/logger.server";
4748

4849
const cronFormat = `* * * * *
4950
┬ ┬ ┬ ┬ ┬
@@ -94,9 +95,9 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
9495
submission.value?.friendlyId === result.id ? "Schedule updated" : "Schedule created"
9596
);
9697
} catch (error: any) {
97-
const errorMessage = `Failed: ${
98-
error instanceof Error ? error.message : JSON.stringify(error)
99-
}`;
98+
logger.error("Failed to create schedule", error);
99+
100+
const errorMessage = `Something went wrong. Please try again.`;
100101
return redirectWithErrorMessage(
101102
v3SchedulesPath({ slug: organizationSlug }, { slug: projectParam }),
102103
request,

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.v3.$projectParam.runs.$runParam.spans.$spanParam/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ function RunTimeline({ run }: { run: SpanRun }) {
857857
<RunTimelineEvent
858858
title="Finished"
859859
subtitle={<DateTimeAccurate date={run.updatedAt} />}
860-
state="complete"
860+
state={run.isError ? "error" : "complete"}
861861
/>
862862
</>
863863
) : (

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",

0 commit comments

Comments
 (0)