MCPcopy
hub / github.com/garrytan/gstack / waitForReady

Function waitForReady

browse/test/pair-agent-e2e.test.ts:38–52  ·  view source on GitHub ↗
(baseUrl: string, timeoutMs = 15_000)

Source from the content-addressed store, hash-verified

36}
37
38async function waitForReady(baseUrl: string, timeoutMs = 15_000): Promise<void> {
39 const deadline = Date.now() + timeoutMs;
40 while (Date.now() < deadline) {
41 try {
42 const resp = await fetch(`${baseUrl}/health`, {
43 signal: AbortSignal.timeout(1000),
44 });
45 if (resp.ok) return;
46 } catch {
47 // not ready yet
48 }
49 await new Promise(r => setTimeout(r, 200));
50 }
51 throw new Error(`Daemon did not become ready within ${timeoutMs}ms`);
52}
53
54async function spawnDaemon(): Promise<DaemonHandle> {
55 const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pair-agent-e2e-'));

Callers 1

spawnDaemonFunction · 0.70

Calls 1

fetchFunction · 0.70

Tested by

no test coverage detected