fix(ui): stop double-dispatching handleError from legacy query hooks

The new global QueryCache.onError already routes every query error through
handleError. The query fetch helpers in these hooks also called handleError
inline, so each failure dispatched twice; today the second call is swallowed
only by the 60s throttle in handleError, which is fragile if that throttle or
handleError ever changes. Drop the inline call from the query paths and let
the throw reach the global sink, which re-derives the same message.

Mutation hooks are left as-is because there is no global MutationCache.onError;
removing their inline handler would drop error reporting entirely.
This commit is contained in:
ryan-crabbe-berri 2026-06-06 21:17:03 -07:00
parent 62d3b5edc2
commit 21bbba687f
5 changed files with 4 additions and 10 deletions

View file

@ -1,6 +1,6 @@
import { keepPreviousData, useQuery, UseQueryResult } from "@tanstack/react-query";
import { createQueryKeys } from "../common/queryKeysFactory";
import { getProxyBaseUrl, getGlobalLitellmHeaderName, deriveErrorMessage, handleError } from "@/components/networking";
import { getProxyBaseUrl, getGlobalLitellmHeaderName, deriveErrorMessage } from "@/components/networking";
import { KeyResponse } from "@/components/key_team_helpers/key_list";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
@ -85,7 +85,6 @@ const keyListCall = async (accessToken: string, page: number, pageSize: number,
if (!response.ok) {
const errorData = await response.json();
const errorMessage = deriveErrorMessage(errorData);
handleError(errorMessage);
throw new Error(errorMessage);
}

View file

@ -1,5 +1,5 @@
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { getProxyBaseUrl, getGlobalLitellmHeaderName, deriveErrorMessage, handleError } from "@/components/networking";
import { getProxyBaseUrl, getGlobalLitellmHeaderName, deriveErrorMessage } from "@/components/networking";
import { all_admin_roles } from "@/utils/roles";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
import { ProjectResponse, projectKeys } from "./useProjects";
@ -21,7 +21,6 @@ const fetchProjectDetails = async (accessToken: string, projectId: string): Prom
if (!response.ok) {
const errorData = await response.json();
const errorMessage = deriveErrorMessage(errorData);
handleError(errorMessage);
throw new Error(errorMessage);
}

View file

@ -1,6 +1,6 @@
import { useQuery } from "@tanstack/react-query";
import { createQueryKeys } from "../common/queryKeysFactory";
import { getProxyBaseUrl, getGlobalLitellmHeaderName, deriveErrorMessage, handleError } from "@/components/networking";
import { getProxyBaseUrl, getGlobalLitellmHeaderName, deriveErrorMessage } from "@/components/networking";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
import { all_admin_roles, internalUserRoles } from "@/utils/roles";
@ -61,7 +61,6 @@ const fetchProjects = async (accessToken: string): Promise<ProjectResponse[]> =>
if (!response.ok) {
const errorData = await response.json();
const errorMessage = deriveErrorMessage(errorData);
handleError(errorMessage);
throw new Error(errorMessage);
}

View file

@ -89,7 +89,6 @@ export const getProxyConfigCall = async (accessToken: string, configType: Config
if (!response.ok) {
const errorData = await response.json();
const errorMessage = deriveErrorMessage(errorData);
handleError(errorMessage);
throw new Error(errorMessage);
}

View file

@ -4,7 +4,7 @@ import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
import { fetchTeams } from "@/app/(dashboard)/networking";
import { createQueryKeys } from "@/app/(dashboard)/hooks/common/queryKeysFactory";
import { teamInfoCall } from "@/components/networking";
import { getProxyBaseUrl, getGlobalLitellmHeaderName, deriveErrorMessage, handleError } from "@/components/networking";
import { getProxyBaseUrl, getGlobalLitellmHeaderName, deriveErrorMessage } from "@/components/networking";
export interface TeamsResponse {
teams: Team[];
@ -72,7 +72,6 @@ export const teamListCall = async (
if (!response.ok) {
const errorData = await response.json();
const errorMessage = deriveErrorMessage(errorData);
handleError(errorMessage);
throw new Error(errorMessage);
}
@ -220,7 +219,6 @@ const deletedTeamListCall = async (
if (!response.ok) {
const errorData = await response.json();
const errorMessage = deriveErrorMessage(errorData);
handleError(errorMessage);
throw new Error(errorMessage);
}