🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(automations): suppress spurious 404 toast on delete, instant not-found detection (#15147)
Tobias Wochinger2a8c15b4cbb6
diff --git a/web/src/features/automations/components/AutomationDetails.tsx b/web/src/features/automations/components/AutomationDetails.tsxindex fb50ee55cf..0fc9532ef7 100644--- a/web/src/features/automations/components/AutomationDetails.tsx+++ b/web/src/features/automations/components/AutomationDetails.tsx@@ -51,6 +51,9 @@ export const AutomationDetails: React.FC<AutomationDetailsProps> = ({},{enabled: !!projectId && !!automationId,+ // Suppress 404 toast: after deletion the invalidation can refetch this+ // query before the component unmounts, producing a spurious error toast.+ meta: { silentHttpCodes: [404] },},);diff --git a/web/src/features/automations/components/AutomationExecutionsTable.tsx b/web/src/features/automations/components/AutomationExecutionsTable.tsxindex b8de0c03b8..c47d453c5b 100644--- a/web/src/features/automations/components/AutomationExecutionsTable.tsx+++ b/web/src/features/automations/components/AutomationExecutionsTable.tsx@@ -41,12 +41,17 @@ export const AutomationExecutionsTable: React.FC<);const { data, isLoading, isError, error } =- api.automations.getAutomationExecutions.useQuery({- projectId,- automationId,- page: paginationState.pageIndex,- limit: paginationState.pageSize,- });+ api.automations.getAutomationExecutions.useQuery(+ {+ projectId,+ automationId,+ page: paginationState.pageIndex,+ limit: paginationState.pageSize,+ },+ // Suppress 404 toast: invalidation after deletion can refetch this query+ // before the component unmounts.+ { meta: { silentHttpCodes: [404] } },+ );const columns: LangfuseColumnDef<ActionExecutionRow>[] = [{diff --git a/web/src/features/automations/components/AutomationSidebar.tsx b/web/src/features/automations/components/AutomationSidebar.tsxindex 717b8ade02..d889aabcbc 100644--- a/web/src/features/automations/components/AutomationSidebar.tsx+++ b/web/src/features/automations/components/AutomationSidebar.tsx@@ -16,9 +16,14 @@ export const AutomationSidebar: React.FC<AutomationSidebarProps> = ({onAutomationSelect,}) => {const { data: automations, isLoading } =- api.automations.getAutomations.useQuery({- projectId,- });+ api.automations.getAutomations.useQuery(+ {+ projectId,+ },+ {+ enabled: !!projectId,+ },+ );const sidebarWidth = "w-40 sm:w-64";diff --git a/web/src/features/automations/components/automations.tsx b/web/src/features/automations/components/automations.tsxindex 36b4b17452..fd26adca00 100644--- a/web/src/features/automations/components/automations.tsx+++ b/web/src/features/automations/components/automations.tsx@@ -57,9 +57,14 @@ export default function AutomationsPage() {);// Fetch automations to check if any exist- const { data: automations } = api.automations.getAutomations.useQuery({- projectId,- });+ const { data: automations } = api.automations.getAutomations.useQuery(+ {+ projectId,+ },+ {+ enabled: !!projectId,+ },+ );// Fetch editing automation when in edit modeconst { data: editingAutomation, error: editingAutomationError } =@@ -70,6 +75,10 @@ export default function AutomationsPage() {},{enabled: view === "edit" && !!automationId,+ // Suppress 404 toast: invalidation after deletion can trigger a refetch+ // before the URL update commits (reachable via the delete button+ // rendered inside AutomationForm on the dedicated edit view).+ meta: { silentHttpCodes: [404] },},);@@ -82,6 +91,11 @@ export default function AutomationsPage() {},{enabled: view === "list" && !!selectedAutomation,+ // Suppress 404 toast: invalidation after deletion can trigger a refetch+ // before the URL update commits. The error *state* is preserved so the+ // NOT_FOUND check below (renderAutomationNotFoundError) still works for+ // stale/invalid automation URLs.+ meta: { silentHttpCodes: [404] },},);diff --git a/web/src/utils/api.ts b/web/src/utils/api.tsindex 62f7201148..6fb0d517f2 100644--- a/web/src/utils/api.ts+++ b/web/src/utils/api.ts@@ -67,6 +67,11 @@ const ERROR_DEBOUNCE_MS = 20000;const hasResponseMeta = (error: TRPCClientError<any>): boolean =>Boolean((error.meta as { response?: unknown } | undefined)?.response);+const getHttpStatus = (error: unknown): number | undefined =>+ error instanceof TRPCClientError && typeof error.data?.httpStatus === "number"+ ? error.data.httpStatus+ : undefined;+const getCause = (error: unknown): unknown =>error instanceof Error ? error.cause : undefined;@@ -280,10 +285,9 @@ const shouldSilenceError = (}if (Array.isArray(meta?.silentHttpCodes)) {+ const httpStatus = getHttpStatus(error);return (- error instanceof TRPCClientError &&- typeof error.data?.httpStatus === "number" &&- meta.silentHttpCodes.includes(error.data?.httpStatus)+ httpStatus !== undefined && meta.silentHttpCodes.includes(httpStatus));}@@ -349,6 +353,17 @@ export const api = createTRPCNext<AppRouter>({queries: {// react query defaults to `online`, but we want to disable it as it caused issues for some usersnetworkMode: "always",+ // Don't retry on 404s: a deleted/missing resource never appears via+ // retry, so failing fast avoids piling up pointless refetches (and+ // ClickHouse load for resources backed by it). Every other 4xx keeps+ // the default retry/backoff — some (e.g. a route param that hasn't+ // hydrated yet, a proxy-level 429) are transient and self-heal.+ retry: (failureCount, error) => {+ if (getHttpStatus(error) === 404) {+ return false;+ }+ return failureCount < 3;+ },},mutations: {onError: (error) => handleTrpcError(error),