Skip to content

Run completed at fix and engine API rate limit whitelist #1899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 8, 2025
Merged
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
6 changes: 3 additions & 3 deletions apps/webapp/app/components/run/RunTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function buildTimelineItems(run: TimelineSpanRun): TimelineItem[] {
items.push({
type: "line",
id: "executing",
title: formatDuration(run.executedAt, run.updatedAt),
title: formatDuration(run.executedAt, run.completedAt ?? run.updatedAt),
state,
shouldRender: true,
variant: "normal",
Expand All @@ -271,7 +271,7 @@ function buildTimelineItems(run: TimelineSpanRun): TimelineItem[] {
items.push({
type: "line",
id: "legacy-executing",
title: formatDuration(run.startedAt, run.updatedAt),
title: formatDuration(run.startedAt, run.completedAt ?? run.updatedAt),
state,
shouldRender: true,
variant: "normal",
Expand All @@ -296,7 +296,7 @@ function buildTimelineItems(run: TimelineSpanRun): TimelineItem[] {
type: "event",
id: "finished",
title: "Finished",
date: run.updatedAt,
date: run.completedAt ?? run.updatedAt,
previousDate: run.executedAt ?? run.startedAt ?? undefined,
state,
shouldRender: true,
Expand Down
7 changes: 4 additions & 3 deletions apps/webapp/app/components/runs/v3/TaskRunsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@ export function TaskRunsTable({
allowSelection = false,
variant = "dimmed",
}: RunsTableProps) {
const user = useUser();
const organization = useOrganization();
const project = useProject();
const environment = useEnvironment();
const checkboxes = useRef<(HTMLInputElement | null)[]>([]);
const { selectedItems, has, hasAll, select, deselect, toggle } = useSelectedItems(allowSelection);
const { isManagedCloud } = useFeatures();

const showCompute = user.admin && isManagedCloud;
const showCompute = isManagedCloud;

const navigateCheckboxes = useCallback(
(event: React.KeyboardEvent<HTMLInputElement>, index: number) => {
Expand Down Expand Up @@ -371,7 +370,9 @@ export function TaskRunsTable({
</TableCell>
{showCompute && (
<TableCell to={path} className="tabular-nums">
{run.costInCents > 0 ? formatCurrencyAccurate(run.costInCents / 100) : "–"}
{run.costInCents > 0
? formatCurrencyAccurate((run.costInCents + run.baseCostInCents) / 100)
: "–"}
</TableCell>
)}
<TableCell to={path}>
Expand Down
6 changes: 5 additions & 1 deletion apps/webapp/app/presenters/v3/RunListPresenter.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export class RunListPresenter extends BasePresenter {
lockedAt: Date | null;
delayUntil: Date | null;
updatedAt: Date;
completedAt: Date | null;
isTest: boolean;
spanId: string;
idempotencyKey: string | null;
Expand Down Expand Up @@ -238,6 +239,7 @@ export class RunListPresenter extends BasePresenter {
tr."delayUntil" AS "delayUntil",
tr."lockedAt" AS "lockedAt",
tr."updatedAt" AS "updatedAt",
tr."completedAt" AS "completedAt",
tr."isTest" AS "isTest",
tr."spanId" AS "spanId",
tr."idempotencyKey" AS "idempotencyKey",
Expand Down Expand Up @@ -383,7 +385,9 @@ WHERE
startedAt: startedAt ? startedAt.toISOString() : undefined,
delayUntil: run.delayUntil ? run.delayUntil.toISOString() : undefined,
hasFinished,
finishedAt: hasFinished ? run.updatedAt.toISOString() : undefined,
finishedAt: hasFinished
? run.completedAt?.toISOString() ?? run.updatedAt.toISOString()
: undefined,
isTest: run.isTest,
status: run.status,
version: run.version,
Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/app/routes/engine.v1.dev.presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { createSSELoader } from "~/utils/sse";
export const loader = createSSELoader({
timeout: env.DEV_PRESENCE_SSE_TIMEOUT,
interval: env.DEV_PRESENCE_TTL_MS * 0.8,
debug: true,
debug: false,
handler: async ({ id, controller, debug, request }) => {
const authentication = await authenticateApiRequestWithFailure(request);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createSSELoader, type SendFunction } from "~/utils/sse";
export const loader = createSSELoader({
timeout: env.DEV_PRESENCE_SSE_TIMEOUT,
interval: env.DEV_PRESENCE_POLL_MS,
debug: true,
debug: false,
handler: async ({ id, controller, debug, request, params }) => {
const userId = await requireUserId(request);
const { organizationSlug, projectParam } = ProjectParamSchema.parse(params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { createSSELoader } from "~/utils/sse";
export const loader = createSSELoader({
timeout: env.QUEUE_SSE_AUTORELOAD_TIMEOUT_MS,
interval: env.QUEUE_SSE_AUTORELOAD_INTERVAL_MS,
debug: true,
debug: false,
handler: async ({ request, params }) => {
const userId = await requireUserId(request);
const { projectParam, envParam } = EnvironmentParamSchema.parse(params);
Expand Down
4 changes: 2 additions & 2 deletions apps/webapp/app/services/engineRateLimit.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const engineRateLimiter = authorizationRateLimitMiddleware({
stale: 60_000 * 20, // Date is stale after 20 minutes
},
pathMatchers: [/^\/engine/],
// Allow /api/v1/tasks/:id/callback/:secret
pathWhiteList: [],
// Regex allow any path starting with /engine/v1/worker-actions/
pathWhiteList: [/^\/engine\/v1\/worker-actions\/.*/],
log: {
rejections: env.RUN_ENGINE_RATE_LIMIT_REJECTION_LOGS_ENABLED === "1",
requests: env.RUN_ENGINE_RATE_LIMIT_REQUEST_LOGS_ENABLED === "1",
Expand Down