Skip to content

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

Chore/delay disk size report (#33686)

Terry Sutton7ffd525da12f
diff --git a/apps/studio/components/interfaces/DiskManagement/fields/DiskSizeField.tsx b/apps/studio/components/interfaces/DiskManagement/fields/DiskSizeField.tsx
index b1d1e2a6589..1fe4709a778 100644
--- a/apps/studio/components/interfaces/DiskManagement/fields/DiskSizeField.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/fields/DiskSizeField.tsx
@@ -6,7 +6,9 @@ import { DocsButton } from 'components/ui/DocsButton'
import { useDiskAttributesQuery } from 'data/config/disk-attributes-query'
import { useDiskUtilizationQuery } from 'data/config/disk-utilization-query'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
+import dayjs from 'dayjs'
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
+import { useSelectedProject } from 'hooks/misc/useSelectedProject'
import { GB } from 'lib/constants'
import { Button, FormControl_Shadcn_, FormField_Shadcn_, Input_Shadcn_, Skeleton, cn } from 'ui'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
@@ -35,6 +37,7 @@ export function DiskSizeField({
const { ref: projectRef } = useParams()
const { control, formState, setValue, trigger, getValues, resetField, watch } = form
const org = useSelectedOrganization()
+ const project = useSelectedProject()
const {
isLoading: isLoadingDiskAttributes,
@@ -59,6 +62,12 @@ export function DiskSizeField({
const error = subscriptionError || diskUtilError || diskAttributesError
const isError = isSubscriptionError || isDiskUtilizationError || isDiskAttributesError
+ // coming up typically takes 5 minutes, and the request is cached for 5 mins
+ // so doing less than 10 mins to account for both
+ const isProjectNew =
+ dayjs.utc().diff(dayjs.utc(project?.inserted_at), 'minute') < 10 ||
+ project?.status === 'COMING_UP'
+
const watchedStorageType = watch('storageType')
const watchedTotalSize = watch('totalSize')
@@ -174,11 +183,20 @@ export function DiskSizeField({
</div>
<div className="col-span-8">
<DiskSpaceBar form={form} />
- {error && (
- <FormMessage message="Failed to load disk size data" type="error">
- {error?.message}
- </FormMessage>
+
+ {isProjectNew ? (
+ <FormMessage
+ message="Disk size data is not available for ~10 minutes after project creation"
+ type="error"
+ />
+ ) : (
+ error && (
+ <FormMessage message="Failed to load disk size data" type="error">
+ {error?.message}
+ </FormMessage>
+ )
)}
+
<DiskManagementDiskSizeReadReplicas
isDirty={formState.dirtyFields.totalSize !== undefined}
totalSize={(formState.defaultValues?.totalSize || 0) * 1.25}