( url: string, init: RequestInit, label: string, timeoutMs = 30000, )
| 161 | } |
| 162 | |
| 163 | async function waitForRequestReady( |
| 164 | url: string, |
| 165 | init: RequestInit, |
| 166 | label: string, |
| 167 | timeoutMs = 30000, |
| 168 | ) { |
| 169 | const start = Date.now(); |
| 170 | |
| 171 | while (true) { |
| 172 | try { |
| 173 | const response = await fetch(url, init); |
| 174 | if (response.ok) { |
| 175 | return; |
| 176 | } |
| 177 | } catch { |
| 178 | // Keep polling until the timeout expires. |
| 179 | } |
| 180 | |
| 181 | if (Date.now() - start > timeoutMs) { |
| 182 | throw new Error(`${label} did not become ready in time.`); |
| 183 | } |
| 184 | |
| 185 | await sleep(300); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | async function warmServer(platform: 'ios' | 'android') { |
| 190 | const origin = `http://127.0.0.1:${LOCAL_UPDATE_PORT}`; |
no test coverage detected