(url, timeoutMs = DEFAULT_WAIT_TIMEOUT_MS)
| 783 | } |
| 784 | |
| 785 | async function waitForServer(url, timeoutMs = DEFAULT_WAIT_TIMEOUT_MS) { |
| 786 | const startedAt = Date.now(); |
| 787 | |
| 788 | while (Date.now() - startedAt < timeoutMs) { |
| 789 | try { |
| 790 | const response = await fetch(url); |
| 791 | if (response.ok) { |
| 792 | return; |
| 793 | } |
| 794 | } catch { |
| 795 | // Keep polling until timeout. |
| 796 | } |
| 797 | |
| 798 | await delay(500); |
| 799 | } |
| 800 | |
| 801 | throw new Error(`Timed out waiting for agent-server at ${url}`); |
| 802 | } |
| 803 | |
| 804 | function spawnProcess(command, args, options = {}) { |
| 805 | const child = spawn( |