mirror of
https://github.com/supabase/supabase.git
synced 2026-05-08 07:50:20 +08:00
* added packages for creating projects * updated scripts * remove ami version * cleaned up common * updated tests * refactored helpers * updated env * updated config * updated to reference env * updated global setup * updated type logic and scripts * added mocking of hcaptcha * added log statements * updated local env * update env file * updated env vars * updated logging * updated to remove check * updated print and project names * updated helpers * updated url * updated setup * updated storage helpers to account for listing files * updated setup and tests * updated timeout only for setup * updated helper to account for different api response * added ignores for tests * updated lock file * updated database spec to add exact * updated timeouts * removed check for table grid footer * updated test runner * updated is_platform * updated playwright config * updated worker settings * removed dotenvx * updated README * updated to remove comment * Update e2e/studio/scripts/common/retriedFetch.ts Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> --------- Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import assert from 'assert'
|
|
|
|
import { PlatformClient } from './platform.js'
|
|
import { sleep } from './helpers.js'
|
|
|
|
const checkHealth = async (platformClient: PlatformClient, ref: string) => {
|
|
// get health of services
|
|
const healthResp = await platformClient.send(
|
|
`/v1/projects/${ref}/health?services=db,pooler,auth,realtime,rest,storage`
|
|
)
|
|
|
|
assert(
|
|
healthResp.status == 200,
|
|
`Failed to get health ${healthResp.status}: ${healthResp.statusText}`
|
|
)
|
|
|
|
const health = await healthResp.json()
|
|
|
|
return health as Health[]
|
|
}
|
|
|
|
type Health = {
|
|
name: string
|
|
healthy: boolean
|
|
status: string
|
|
info?: unknown
|
|
error?: unknown
|
|
}
|
|
|
|
export const waitForHealthyServices = async (platformClient: PlatformClient, ref: string) => {
|
|
// check health 600 times every 2 seconds; 20mins
|
|
for (let i = 0; i < 600; i++) {
|
|
try {
|
|
const health = await checkHealth(platformClient, ref)
|
|
// check if all services are healthy
|
|
if (health.every((h) => h.healthy)) {
|
|
return
|
|
}
|
|
console.log(`waiting ${i} ... services: ${JSON.stringify(health.filter((h) => !h.healthy))}`)
|
|
} catch (e) {
|
|
console.log(`waiting ${i} ... errored: ${(e as { message: string }).message}`)
|
|
}
|
|
|
|
await sleep(2000)
|
|
}
|
|
throw new Error('Services are not healthy')
|
|
}
|