MCPcopy
hub / github.com/ThatGuySam/doesitarm / waitForServer

Function waitForServer

test/playwright/support/astro-browser-test.ts:71–90  ·  view source on GitHub ↗
( url: string, {
    intervalMs = 250,
    timeoutMs = 60 * 1000
} = {} )

Source from the content-addressed store, hash-verified

69}
70
71export async function waitForServer ( url: string, {
72 intervalMs = 250,
73 timeoutMs = 60 * 1000
74} = {} ) {
75 const startedAt = Date.now()
76
77 while ( Date.now() - startedAt < timeoutMs ) {
78 try {
79 const response = await fetch( url )
80
81 if ( response.ok ) {
82 return
83 }
84 } catch {}
85
86 await new Promise( resolve => setTimeout( resolve, intervalMs ) )
87 }
88
89 throw new Error( `Timed out waiting for dev server at ${ url }` )
90}
91
92export async function startAstroDevServer ( {
93 env = {},

Callers 1

startAstroDevServerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected