Skip to content

Commit 09e7111

Browse files
authored
UI: Fix double-loading of API data on pages with slow rendering (prometheus#17357)
Without `staleTime: Infinity`, the query data would be immediately marked stale, and in combination with the `gcTime: 0` setting and a brief unmount during data loading (via Suspense), the data would have to be reloaded a second time during/after the first real render. `gcTime: 0` + `staleTime: Infinity` should give us the desired behavior where data loaded for a page should be valid forever as long as that page is being displayed, but always thrown away (and later reloaded) whenever we navigate away and again to that page. Signed-off-by: Julius Volz <julius.volz@gmail.com>
1 parent a3e4047 commit 09e7111

File tree

1 file changed

+1
-0
lines changed
  • web/ui/mantine-ui/src/api

1 file changed

+1
-0
lines changed

web/ui/mantine-ui/src/api/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export const useSuspenseAPIQuery = <T>({ key, path, params }: QueryOptions) => {
125125
queryKey: key !== undefined ? key : [path, params],
126126
retry: false,
127127
refetchOnWindowFocus: false,
128+
staleTime: Infinity, // Required for suspense queries since the component is briefly unmounted when loading the data, which together with a gcTime of 0 will cause the data to be garbage collected before it can be used.
128129
gcTime: 0,
129130
queryFn: createQueryFn({ pathPrefix, path, params }),
130131
});

0 commit comments

Comments
 (0)