MCPcopy Create free account
hub / github.com/TanStack/db / waitForElectric

Function waitForElectric

packages/db-collection-e2e/support/global-setup.ts:46–70  ·  view source on GitHub ↗

* Wait for Electric server to be ready

(url: string)

Source from the content-addressed store, hash-verified

44 * Wait for Electric server to be ready
45 */
46async function waitForElectric(url: string): Promise<void> {
47 return new Promise<void>((resolve, reject) => {
48 const timeout = setTimeout(() => {
49 reject(new Error(`Timed out waiting for Electric to be active at ${url}`))
50 }, 10000)
51
52 const check = async (): Promise<void> => {
53 try {
54 const res = await fetch(`${url}/v1/health`)
55 if (res.ok) {
56 const data = (await res.json()) as { status: string }
57 if (data.status === 'active') {
58 clearTimeout(timeout)
59 return resolve()
60 }
61 }
62 setTimeout(() => void check(), 100)
63 } catch {
64 setTimeout(() => void check(), 100)
65 }
66 }
67
68 void check()
69 })
70}
71
72/**
73 * Wait for Postgres to be ready

Callers 1

global-setup.tsFile · 0.85

Calls 1

checkFunction · 0.70

Tested by

no test coverage detected