Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: Add exponential backoff to the incident queries (#43773)

Ivan Vasilov2c81ca5763d9
diff --git a/apps/studio/data/platform/incident-banner-query.ts b/apps/studio/data/platform/incident-banner-query.ts
index 9832c8833d1..d6ee71419bb 100644
--- a/apps/studio/data/platform/incident-banner-query.ts
+++ b/apps/studio/data/platform/incident-banner-query.ts
@@ -31,6 +31,10 @@ export const incidentBannerQueryOptions = () =>
queryOptions({
queryKey: platformKeys.incidentBanner(),
queryFn: ({ signal }) => getIncidentBanner(signal),
+ refetchOnWindowFocus: false,
+ // exponential backoff retry starting at 4s, 16s, 64s, 256s etc. Hard capped at 5 minutes to prevent excessively
+ // long retry delays.
+ retryDelay: (attemptIndex) => Math.min(1000 * 4 ** attemptIndex, 1000 * 60 * 5),
staleTime: 1000 * 60 * 5,
enabled: IS_PLATFORM,
})
diff --git a/apps/studio/data/platform/incident-status-query.ts b/apps/studio/data/platform/incident-status-query.ts
index 7c767fc1cb5..37076f7644d 100644
--- a/apps/studio/data/platform/incident-status-query.ts
+++ b/apps/studio/data/platform/incident-status-query.ts
@@ -40,6 +40,10 @@ export const useIncidentStatusQuery = <TData = IncidentStatusData>(
useQuery<IncidentStatusData, IncidentStatusError, TData>({
queryKey: platformKeys.incidentStatus(),
queryFn: ({ signal }) => getIncidentStatus(signal),
+ refetchOnWindowFocus: false,
+ // exponential backoff retry starting at 4s, 16s, 64s, 256s etc. Hard capped at 5 minutes to prevent excessively
+ // long retry delays.
+ retryDelay: (attemptIndex) => Math.min(1000 * 4 ** attemptIndex, 1000 * 60 * 5),
staleTime: 1000 * 60 * 5, // 5 minutes to match API cache
...options,
// Enable in platform mode, or in test environment for E2E testing