🪢 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
chore(trpc): handling of errors with body parse issues (#13211)
marliessophied4aa05a4d2e6
diff --git a/web/src/utils/trpcErrorToast.tsx b/web/src/utils/trpcErrorToast.tsxindex cdb7fd4704..cb73167be8 100644--- a/web/src/utils/trpcErrorToast.tsx+++ b/web/src/utils/trpcErrorToast.tsx@@ -3,6 +3,15 @@ import { showErrorToast } from "@/src/features/notifications/showErrorToast";// Catch network level errors, e.g. by proxy rate-limiting+/**+ * Check if error was caused by a response parsing failure.+ * This happens when infrastructure (nginx, cloudflare, etc.) returns a non-JSON+ * response body (e.g., empty body on 431, HTML error page on 502/503/504).+ */+const isResponseParseError = (error: TRPCClientError<any>): boolean => {+ return error.cause instanceof SyntaxError;+};+const httpStatusOverride: Record<number, keyof typeof errorTitleMap> = {429: "TOO_MANY_REQUESTS",524: "TIMEOUT",@@ -61,6 +70,17 @@ const getErrorDescription = (httpStatus: number) => {export const trpcErrorToast = (error: unknown) => {if (error instanceof TRPCClientError) {+ // Handle infrastructure-level errors that return non-JSON responses+ // (e.g., 431 with empty body, 502/503/504 with HTML error pages)+ if (isResponseParseError(error)) {+ showErrorToast(+ "Unexpected Response",+ "The request could not be completed. We've been notified and are looking into it. Please try again or contact support if this persists.",+ "WARNING",+ );+ return;+ }+const { errorTitle, httpStatus } = getErrorTitleAndHttpCode(error);const path = error.data?.path;