Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 60 additions & 55 deletions apps/webapp/app/routes/engine.v1.dev.runs.$runFriendlyId.logs.debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,64 +11,69 @@ import { logger } from "~/services/logger.server";
import { createActionApiRoute } from "~/services/routeBuilders/apiBuilder.server";
import { recordRunDebugLog } from "~/v3/eventRepository.server";

const { action } = createActionApiRoute(
{
params: z.object({
runFriendlyId: z.string(),
}),
body: WorkerApiDebugLogBody,
method: "POST",
},
async ({
authentication,
body,
params,
}): Promise<TypedResponse<WorkerApiRunAttemptStartResponseBody>> => {
const { runFriendlyId } = params;
// const { action } = createActionApiRoute(
// {
// params: z.object({
// runFriendlyId: z.string(),
// }),
// body: WorkerApiDebugLogBody,
// method: "POST",
// },
// async ({
// authentication,
// body,
// params,
// }): Promise<TypedResponse<WorkerApiRunAttemptStartResponseBody>> => {
// const { runFriendlyId } = params;

try {
const run = await prisma.taskRun.findFirst({
where: {
friendlyId: params.runFriendlyId,
runtimeEnvironmentId: authentication.environment.id,
},
});
// try {
// const run = await prisma.taskRun.findFirst({
// where: {
// friendlyId: params.runFriendlyId,
// runtimeEnvironmentId: authentication.environment.id,
// },
// });

if (!run) {
throw new Response("You don't have permissions for this run", { status: 401 });
}
// if (!run) {
// throw new Response("You don't have permissions for this run", { status: 401 });
// }

const eventResult = await recordRunDebugLog(
RunId.fromFriendlyId(runFriendlyId),
body.message,
{
attributes: {
properties: body.properties,
},
startTime: body.time,
}
);
// const eventResult = await recordRunDebugLog(
// RunId.fromFriendlyId(runFriendlyId),
// body.message,
// {
// attributes: {
// properties: body.properties,
// },
// startTime: body.time,
// }
// );

if (eventResult.success) {
return new Response(null, { status: 204 });
}
// if (eventResult.success) {
// return new Response(null, { status: 204 });
// }

switch (eventResult.code) {
case "FAILED_TO_RECORD_EVENT":
return new Response(null, { status: 400 }); // send a 400 to prevent retries
case "RUN_NOT_FOUND":
return new Response(null, { status: 404 });
default:
return assertExhaustive(eventResult.code);
}
} catch (error) {
logger.error("Failed to record dev log", {
environmentId: authentication.environment.id,
error,
});
throw error;
}
}
);
// switch (eventResult.code) {
// case "FAILED_TO_RECORD_EVENT":
// return new Response(null, { status: 400 }); // send a 400 to prevent retries
// case "RUN_NOT_FOUND":
// return new Response(null, { status: 404 });
// default:
// return assertExhaustive(eventResult.code);
// }
// } catch (error) {
// logger.error("Failed to record dev log", {
// environmentId: authentication.environment.id,
// error,
// });
// throw error;
// }
// }
// );

export { action };
// export { action };

// Create a generic JSON action in remix
export function action() {
return new Response(null, { status: 204 });
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,39 @@ import { z } from "zod";
import { createActionWorkerApiRoute } from "~/services/routeBuilders/apiBuilder.server";
import { recordRunDebugLog } from "~/v3/eventRepository.server";

export const action = createActionWorkerApiRoute(
{
params: z.object({
runFriendlyId: z.string(),
}),
body: WorkerApiDebugLogBody,
},
async ({ body, params }): Promise<Response> => {
const { runFriendlyId } = params;
// export const action = createActionWorkerApiRoute(
// {
// params: z.object({
// runFriendlyId: z.string(),
// }),
// body: WorkerApiDebugLogBody,
// },
// async ({ body, params }): Promise<Response> => {
// const { runFriendlyId } = params;

const eventResult = await recordRunDebugLog(RunId.fromFriendlyId(runFriendlyId), body.message, {
attributes: {
properties: body.properties,
},
startTime: body.time,
});
// const eventResult = await recordRunDebugLog(RunId.fromFriendlyId(runFriendlyId), body.message, {
// attributes: {
// properties: body.properties,
// },
// startTime: body.time,
// });

if (eventResult.success) {
return new Response(null, { status: 204 });
}
// if (eventResult.success) {
// return new Response(null, { status: 204 });
// }

switch (eventResult.code) {
case "FAILED_TO_RECORD_EVENT":
return new Response(null, { status: 400 }); // send a 400 to prevent retries
case "RUN_NOT_FOUND":
return new Response(null, { status: 404 });
default:
return assertExhaustive(eventResult.code);
}
}
);
// switch (eventResult.code) {
// case "FAILED_TO_RECORD_EVENT":
// return new Response(null, { status: 400 }); // send a 400 to prevent retries
// case "RUN_NOT_FOUND":
// return new Response(null, { status: 404 });
// default:
// return assertExhaustive(eventResult.code);
// }
// }
// );

// Create a generic JSON action in remix
export function action() {
return new Response(null, { status: 204 });
}
2 changes: 0 additions & 2 deletions apps/webapp/app/routes/healthcheck.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { prisma } from "~/db.server";
import type { LoaderFunction } from "@remix-run/node";

export const loader: LoaderFunction = async ({ request }) => {
try {
await prisma.user.count();
return new Response("OK");
} catch (error: unknown) {
console.log("healthcheck ❌", { error });
Expand Down