(fn, timeoutMs, label)
| 284 | } |
| 285 | |
| 286 | async function waitFor(fn, timeoutMs, label) { |
| 287 | const start = Date.now() |
| 288 | let lastError = null |
| 289 | |
| 290 | while (Date.now() - start < timeoutMs) { |
| 291 | try { |
| 292 | const result = await fn() |
| 293 | if (result) return result |
| 294 | } catch (error) { |
| 295 | lastError = error |
| 296 | } |
| 297 | await new Promise((resolve) => setTimeout(resolve, 200)) |
| 298 | } |
| 299 | |
| 300 | const suffix = lastError ? ` Last error: ${lastError.message}` : '' |
| 301 | throw new Error(`${label} not ready within ${timeoutMs}ms.${suffix}`) |
| 302 | } |
| 303 | |
| 304 | async function getRendererDebuggerUrl(port) { |
| 305 | return waitFor( |
no test coverage detected