MCPcopy Create free account
hub / github.com/cloudflare/computer / waitForHealth

Function waitForHealth

script/computerd-stub-soak.mjs:164–177  ·  view source on GitHub ↗
(port, child, deadlineMs = 5000)

Source from the content-addressed store, hash-verified

162}
163
164async function waitForHealth(port, child, deadlineMs = 5000) {
165 const started = Date.now();
166 while (Date.now() - started < deadlineMs) {
167 if (child.exitCode !== null) {
168 throw new Error(`computerd exited early with code ${child.exitCode}`);
169 }
170 try {
171 const r = await httpGet(`http://127.0.0.1:${port}/health`);
172 if (r.statusCode === 200) return;
173 } catch {}
174 await sleep(50);
175 }
176 throw new Error("computerd never reported healthy");
177}
178
179async function targetSnapshot(port) {
180 const r = await httpGet(`http://127.0.0.1:${port}/__computerd/stubs`);

Callers 1

mainFunction · 0.70

Calls 2

httpGetFunction · 0.85
sleepFunction · 0.85

Tested by

no test coverage detected