Reduce retry count and show errors on admin pages

TanStack Query's default 3 retries + exponential backoff hid backend
errors behind 5-8s of "Loading…". Now retries once and surfaces the
error message immediately on failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
curo1305
2026-04-17 20:55:13 +02:00
parent 4e9ed97b05
commit a28f847572
2 changed files with 14 additions and 2 deletions
+7 -1
View File
@@ -15,9 +15,10 @@ import {
export default function AdminGroupsPage() {
const queryClient = useQueryClient();
const { data: groups = [], isLoading } = useQuery({
const { data: groups = [], isLoading, isError, error } = useQuery({
queryKey: ["admin-groups"],
queryFn: adminListGroups,
retry: 1,
});
const [showForm, setShowForm] = useState(false);
@@ -97,6 +98,11 @@ export default function AdminGroupsPage() {
{isLoading ? (
<p>Loading</p>
) : isError ? (
<p style={{ color: "red" }}>
Failed to load groups:{" "}
{(error as any)?.response?.data?.detail ?? (error as any)?.message ?? "Unknown error"}
</p>
) : (
<table style={{ width: "100%", borderCollapse: "collapse", marginBottom: 24 }}>
<thead>
+7 -1
View File
@@ -13,9 +13,10 @@ import {
export default function AdminUsersPage() {
const queryClient = useQueryClient();
const { data: me } = useQuery({ queryKey: ["me"], queryFn: getMe });
const { data: users = [], isLoading } = useQuery({
const { data: users = [], isLoading, isError, error } = useQuery({
queryKey: ["admin-users"],
queryFn: adminGetUsers,
retry: 1,
});
const [showForm, setShowForm] = useState(false);
@@ -71,6 +72,11 @@ export default function AdminUsersPage() {
{isLoading ? (
<p>Loading</p>
) : isError ? (
<p style={{ color: "red" }}>
Failed to load users:{" "}
{(error as any)?.response?.data?.detail ?? (error as any)?.message ?? "Unknown error"}
</p>
) : (
<table style={{ width: "100%", borderCollapse: "collapse", marginBottom: 24 }}>
<thead>