mirror of
https://github.com/supabase/supabase.git
synced 2026-06-28 03:19:09 -04:00
ea909e998b
## Context > [!IMPORTANT] > Changes in this PR only apply to the local environment - there should not be any changes to staging (nor production) Given that read replicas currently sit under database replication, the UI currently waits for replication destinations to load before rendering the page. However for local development, setting up of the ETL API isn't necessary nor applicable for everyone so this indirectly adds friction if we just want to work with read replicas. ## Changes involved - Opting to skip retrying fetching ETL related requests if the error returned is "replication API URL is not configured" - This is indicative that the local platform isn't set up for ETL yet - ^ Database replication page will hence not wait for ETL requests to succeed before finally rendering the UI - Node diagram will also then render properly (just read replicas) - Add a small admonition to visualize this <img width="1079" height="301" alt="image" src="https://github.com/user-attachments/assets/32bd5d2f-a76e-417e-bedf-9a04de3bb305" /> ## To test - Will only be able to test locally - basically just head over to the database replication page (unless you somehow already have ETL API set up locally) - But can also verify that there's no changes on staging preview <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved error messaging when ETL is not configured in local development environments * Enhanced error handling for replication API failures with better non-retryable error detection * **Improvements** * Refined replication diagram rendering based on destination setup state * Updated dropdown menu interactions for read replica management <!-- end of auto-generated comment: release notes by coderabbit.ai -->
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { MAX_RETRY_FAILURE_COUNT } from '@/data/query-client'
|
|
import { ResponseError } from '@/types'
|
|
|
|
const isLocal =
|
|
process.env.NEXT_PUBLIC_ENVIRONMENT !== 'prod' &&
|
|
process.env.NEXT_PUBLIC_ENVIRONMENT !== 'staging'
|
|
|
|
export const checkLocalETLNotSetUp = (error: ResponseError | null) => {
|
|
if (error === null) return false
|
|
|
|
const isETLAPINotRunning =
|
|
error.code === undefined && error.message.includes('API error happened')
|
|
const isETLNotSetUp =
|
|
error.code === 503 && error.message.includes('replication API URL is not configured')
|
|
return isLocal && (isETLAPINotRunning || isETLNotSetUp)
|
|
}
|
|
|
|
export const checkReplicationFeatureFlagRetry = (
|
|
failureCount: number,
|
|
error: ResponseError
|
|
): boolean => {
|
|
const isFeatureFlagRequiredError =
|
|
error instanceof ResponseError &&
|
|
error.code === 503 &&
|
|
error.message.includes('feature flag is required')
|
|
|
|
const isLocalETLNotSetUp = checkLocalETLNotSetUp(error)
|
|
|
|
if (isFeatureFlagRequiredError || isLocalETLNotSetUp) {
|
|
return false
|
|
}
|
|
|
|
if (failureCount < MAX_RETRY_FAILURE_COUNT) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|