Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(web): stop retrying 403 and 404 responses

Andrej9964773a695a
diff --git a/apps/web/src/hooks/queries/project/use-get-project.ts b/apps/web/src/hooks/queries/project/use-get-project.ts
index 830ad2f62..d6004f68c 100644
--- a/apps/web/src/hooks/queries/project/use-get-project.ts
+++ b/apps/web/src/hooks/queries/project/use-get-project.ts
@@ -1,7 +1,5 @@
import { useQuery } from "@tanstack/react-query";
import getProject from "@/fetchers/project/get-project";
-import { isUnauthorizedError } from "@/lib/http-error";
-import { getProjectUnavailableReason } from "@/lib/project-unavailable-reason";
function useGetProject({
id,
@@ -14,10 +12,6 @@ function useGetProject({
queryFn: () => getProject({ id, workspaceId }),
queryKey: ["projects", workspaceId, id],
enabled: !!id,
- retry: (failureCount, error) =>
- !isUnauthorizedError(error) &&
- !getProjectUnavailableReason(error) &&
- failureCount < 2,
});
}
diff --git a/apps/web/src/lib/is-forbidden-or-not-found.ts b/apps/web/src/lib/is-forbidden-or-not-found.ts
new file mode 100644
index 000000000..19bd73467
--- /dev/null
+++ b/apps/web/src/lib/is-forbidden-or-not-found.ts
@@ -0,0 +1,7 @@
+import { HttpError } from "./http-error";
+
+export function isForbiddenOrNotFound(error: unknown): boolean {
+ return (
+ error instanceof HttpError && (error.status === 403 || error.status === 404)
+ );
+}
diff --git a/apps/web/src/query-client/index.ts b/apps/web/src/query-client/index.ts
index befd3f98b..5e56e6ebb 100644
--- a/apps/web/src/query-client/index.ts
+++ b/apps/web/src/query-client/index.ts
@@ -1,6 +1,7 @@
import * as Sentry from "@sentry/react";
import { MutationCache, QueryCache, QueryClient } from "@tanstack/react-query";
import { handleUnauthorized, isUnauthorizedError } from "@/lib/http-error";
+import { isForbiddenOrNotFound } from "@/lib/is-forbidden-or-not-found";
// TanStack raises these before any fetcher-level message exists; CORS rejections
// from the browser also surface here. Used both to skip auto-retry and to tag
@@ -79,7 +80,9 @@ const queryClient = new QueryClient({
refetchOnWindowFocus: false,
refetchOnMount: false,
retry: (failureCount, error) =>
- isNetworkError(error) || isUnauthorizedError(error)
+ isNetworkError(error) ||
+ isUnauthorizedError(error) ||
+ isForbiddenOrNotFound(error)
? false
: failureCount < 2,
},