MCPcopy Index your code
hub / github.com/deepnote/deepnote / waitForServer

Function waitForServer

packages/runtime-core/src/server-starter.ts:159–176  ·  view source on GitHub ↗
(info: ServerInfo, timeoutMs: number)

Source from the content-addressed store, hash-verified

157 * Wait for the server to respond to health checks.
158 */
159export async function waitForServer(info: ServerInfo, timeoutMs: number): Promise<void> {
160 const startTime = Date.now()
161
162 while (Date.now() - startTime < timeoutMs) {
163 try {
164 const response = await fetch(`${info.url}/api`)
165 if (response.ok) {
166 return
167 }
168 } catch {
169 // Server not ready yet
170 }
171
172 await sleep(HEALTH_CHECK_INTERVAL_MS)
173 }
174
175 throw new Error(`Server failed to start within ${timeoutMs}ms at ${info.url}`)
176}
177
178function sleep(ms: number): Promise<void> {
179 return new Promise(resolve => setTimeout(resolve, ms))

Callers 1

startServerFunction · 0.85

Calls 1

sleepFunction · 0.85

Tested by

no test coverage detected