Skip to content

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

Fix log drains error handling (#41343)

Joshen Lim84e5df97ea28
diff --git a/apps/studio/components/interfaces/LogDrains/LogDrains.tsx b/apps/studio/components/interfaces/LogDrains/LogDrains.tsx
index ae111a56349..6bc48cfaa35 100644
--- a/apps/studio/components/interfaces/LogDrains/LogDrains.tsx
+++ b/apps/studio/components/interfaces/LogDrains/LogDrains.tsx
@@ -82,6 +82,10 @@ export function LogDrains({
return <LogDrainsEmpty />
}
+ if (isError) {
+ return <AlertError subject="Failed to load log drains" error={error}></AlertError>
+ }
+
if (!isLoading && !hasLogDrains) {
return (
<>
@@ -104,10 +108,6 @@ export function LogDrains({
)
}
- if (isError) {
- return <AlertError error={error}></AlertError>
- }
-
return (
<>
<Card>
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
index 9ab064fbb45..af5a7161460 100644
--- a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
@@ -7,16 +7,7 @@ import { generateSettingsMenu } from 'components/layouts/ProjectSettingsLayout/S
import type { Route } from 'components/ui/ui.types'
import { EditorIndexPageLink } from 'data/prefetchers/project.$ref.editor'
import type { Project } from 'data/projects/project-detail-query'
-import {
- Auth,
- Database,
- EdgeFunctions,
- Realtime,
- Reports,
- SqlEditor,
- Storage,
- TableEditor,
-} from 'icons'
+import { Auth, Database, EdgeFunctions, Realtime, SqlEditor, Storage, TableEditor } from 'icons'
import { IS_PLATFORM, PROJECT_STATUS } from 'lib/constants'
export const generateToolRoutes = (ref?: string, project?: Project, features?: {}): Route[] => {
@@ -193,7 +184,9 @@ export const generateSettingsRoutes = (ref?: string, project?: Project): Route[]
key: 'settings',
label: 'Project Settings',
icon: <Settings size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
- link: ref && `/project/${ref}/settings/general`,
+ link:
+ ref &&
+ (IS_PLATFORM ? `/project/${ref}/settings/general` : `/project/${ref}/settings/log-drains`),
items: settingsMenu,
},
]
diff --git a/apps/studio/data/log-drains/log-drains-query.ts b/apps/studio/data/log-drains/log-drains-query.ts
index a5d616e5abf..d5567c47fe5 100644
--- a/apps/studio/data/log-drains/log-drains-query.ts
+++ b/apps/studio/data/log-drains/log-drains-query.ts
@@ -1,5 +1,6 @@
import { useQuery } from '@tanstack/react-query'
import { get, handleError } from 'data/fetchers'
+import { MAX_RETRY_FAILURE_COUNT } from 'data/query-client'
import type { ResponseError, UseCustomQueryOptions } from 'types'
import { logDrainsKeys } from './keys'
@@ -37,5 +38,12 @@ export const useLogDrainsQuery = <TData = LogDrainsData>(
queryFn: ({ signal }) => getLogDrains({ ref }, signal),
enabled: enabled && !!ref,
refetchOnMount: false,
+ retry: (failureCount, error) => {
+ if (error.code === 500 || error.message.includes('API error happened')) return false
+ if (failureCount < MAX_RETRY_FAILURE_COUNT) {
+ return true
+ }
+ return false
+ },
...options,
})