Skip to content

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

fix: timeout duration

phamhieue0c92b179572
diff --git a/studio/components/layouts/ProjectLayout/ConnectingState.tsx b/studio/components/layouts/ProjectLayout/ConnectingState.tsx
index fdef9148409..7a5c9bbf70a 100644
--- a/studio/components/layouts/ProjectLayout/ConnectingState.tsx
+++ b/studio/components/layouts/ProjectLayout/ConnectingState.tsx
@@ -19,9 +19,9 @@ const ProjectRestartingState: FC<Props> = ({ project }) => {
useEffect(() => {
if (!project.restUrl || !project.internalApiKey) return
- // Check project connection status every 7 seconds
- // pingPostgrest timeouts in 5s, wait for another 2s before checking again
- checkProjectConnectionIntervalRef.current = window.setInterval(testProjectConnection, 7000)
+ // Check project connection status every 4 seconds
+ // pingPostgrest timeouts in 2s, wait for another 2s before checking again
+ checkProjectConnectionIntervalRef.current = window.setInterval(testProjectConnection, 4000)
return () => {
clearInterval(checkProjectConnectionIntervalRef.current)
}
diff --git a/studio/lib/pingPostgrest.ts b/studio/lib/pingPostgrest.ts
index d0db315742c..8778ea5b06d 100644
--- a/studio/lib/pingPostgrest.ts
+++ b/studio/lib/pingPostgrest.ts
@@ -2,7 +2,7 @@ import semver from 'semver'
import { headWithTimeout, getWithTimeout } from './common/fetch'
/**
- * Ping Postgrest for health check. Default timeout in 5s.
+ * Ping Postgrest for health check. Default timeout in 2s.
*
* Project with version gte 'kps-v3.8.6', we can ping the health-check api
* else ping the OpenApi url
@@ -36,6 +36,8 @@ async function pingPostgrest(
}
export default pingPostgrest
+const DEFAULT_TIMEOUT_MILLISECONDS = 2000
+
/**
* Send a HEAD request to postgrest OpenAPI.
*
@@ -46,7 +48,7 @@ async function pingOpenApi(url: string, apikey: string, timeout?: number) {
const { error } = await headWithTimeout(url, [], {
headers,
credentials: 'omit',
- timeout: timeout ?? 5000,
+ timeout: timeout ?? DEFAULT_TIMEOUT_MILLISECONDS,
})
return error === undefined
}
@@ -61,7 +63,7 @@ async function pingHealthCheckApi(url: string, apikey: string, timeout?: number)
const { error } = await getWithTimeout(url, {
headers,
credentials: 'omit',
- timeout: timeout ?? 5000,
+ timeout: timeout ?? DEFAULT_TIMEOUT_MILLISECONDS,
})
return error === undefined
}
diff --git a/studio/stores/app/ProjectStore.ts b/studio/stores/app/ProjectStore.ts
index 0d304a59366..bd0a9af0f1d 100644
--- a/studio/stores/app/ProjectStore.ts
+++ b/studio/stores/app/ProjectStore.ts
@@ -36,8 +36,6 @@ export default class ProjectStore extends PostgresMetaInterface<Project> {
) {
const success = await pingPostgrest(project.restUrl, project.internalApiKey, {
kpsVersion: project.kpsVersion,
- // only wait for 2s. to improve project first load
- timeout: 2000,
})
project.postgrestStatus = success ? 'ONLINE' : 'OFFLINE'
}