()
| 34 | } |
| 35 | |
| 36 | async function waitForHealth() { |
| 37 | const deadline = Date.now() + READY_TIMEOUT_MS; |
| 38 | while (Date.now() < deadline) { |
| 39 | try { |
| 40 | const res = await fetch(`http://127.0.0.1:${PORT}/health`); |
| 41 | if (res.ok) return; |
| 42 | } catch { |
| 43 | // not ready yet |
| 44 | } |
| 45 | await wait(500); |
| 46 | } |
| 47 | throw new Error(`runner did not become healthy within ${READY_TIMEOUT_MS}ms`); |
| 48 | } |
| 49 | |
| 50 | async function postRun() { |
| 51 | const ctrl = new AbortController(); |