MCPcopy Create free account
hub / github.com/TanStack/cli / waitForServer

Function waitForServer

packages/cli/tests-e2e/helpers.ts:88–112  ·  view source on GitHub ↗
(url: string, timeoutMs = 90_000)

Source from the content-addressed store, hash-verified

86}
87
88function waitForServer(url: string, timeoutMs = 90_000) {
89 const started = Date.now()
90 return new Promise<void>((resolvePromise, rejectPromise) => {
91 const attempt = async () => {
92 try {
93 const response = await fetch(url)
94 if (response.ok) {
95 resolvePromise()
96 return
97 }
98 } catch {
99 // keep waiting
100 }
101
102 if (Date.now() - started > timeoutMs) {
103 rejectPromise(new Error(`Timed out waiting for server: ${url}`))
104 return
105 }
106
107 setTimeout(attempt, 500)
108 }
109
110 void attempt()
111 })
112}
113
114function stripAnsi(value: string) {
115 return value.replace(/\u001b\[[0-9;]*m/g, '')

Callers 1

createAppFixtureFunction · 0.85

Calls 2

attemptFunction · 0.85
nowMethod · 0.80

Tested by

no test coverage detected