(url, timeoutMs)
| 169 | } |
| 170 | |
| 171 | async function waitForHttpOk(url, timeoutMs) { |
| 172 | const deadline = Date.now() + timeoutMs |
| 173 | let lastError = null |
| 174 | while (Date.now() < deadline) { |
| 175 | try { |
| 176 | await httpGetJson(url) |
| 177 | return |
| 178 | } catch (err) { |
| 179 | lastError = err |
| 180 | await sleep(100) |
| 181 | } |
| 182 | } |
| 183 | throw new Error(`Timed out waiting for ${url}: ${lastError?.message ?? 'unknown error'}`) |
| 184 | } |
| 185 | |
| 186 | function formatIndex(index) { |
| 187 | return String(index).padStart(5, '0') |
no test coverage detected