diff --git a/apps/provider-console/package.json b/apps/provider-console/package.json index be7a79762..64a049c89 100644 --- a/apps/provider-console/package.json +++ b/apps/provider-console/package.json @@ -1,6 +1,6 @@ { "name": "@akashnetwork/provider-console", - "version": "1.0.1", + "version": "1.0.2", "private": true, "scripts": { "build": "npm run build-env-schemas && next build", diff --git a/apps/provider-console/src/queries/useProviderQuery.ts b/apps/provider-console/src/queries/useProviderQuery.ts index a071fcb33..5164b6af9 100644 --- a/apps/provider-console/src/queries/useProviderQuery.ts +++ b/apps/provider-console/src/queries/useProviderQuery.ts @@ -20,12 +20,7 @@ import { sanitizeMachineAccess } from "@src/utils/sanityUtils"; type ToastParameters = Omit<ToasterToast, "id">; -const handleQueryError = ( - error: AxiosError, - toast: (props: ToastParameters) => unknown, - customMessage?: string, - customTitle = "Uh oh! Something went wrong." -) => { +const handleQueryError = (error: AxiosError, toast: (props: ToastParameters) => unknown, customMessage?: string, customTitle = "Please try again") => { toast({ variant: "destructive", title: customTitle, @@ -106,7 +101,12 @@ export const useProviderDetails = (address: string | undefined) => { try { return await consoleClient.get(`/v1/providers/${address}`); } catch (error: unknown) { - return handleQueryError(error as AxiosError, toast, "Failed to fetch provider details"); + const axiosError = error as AxiosError; + // Don't show toast for 404 errors as it's an expected response for non-providers + if (axiosError.response?.status === 404) { + throw error; + } + return handleQueryError(axiosError, toast, "Failed to fetch provider details"); } }, refetchOnWindowFocus: false, @@ -129,11 +129,22 @@ export const useProviderDashboard = (address: string | undefined) => { try { return await consoleClient.get(`/internal/provider-dashboard/${address}`); } catch (error: unknown) { - return handleQueryError(error as AxiosError, toast, "Failed to fetch provider dashboard"); + const axiosError = error as AxiosError; + // Don't show toast for 404 errors as it's an expected response for non-providers + if (axiosError.response?.status === 404) { + throw error; + } + return handleQueryError(axiosError, toast, "Failed to fetch provider dashboard"); } }, refetchOnWindowFocus: false, - retry: 3, + retry: (failureCount, error: AxiosError) => { + const status = error.response?.status; + if (status && status >= 400 && status < 500) { + return false; + } + return failureCount < 3; + }, enabled: !!address }); };