(request: { path: string; version: number; after?: number })
| 519 | } |
| 520 | |
| 521 | async function waitForFullDiagnostics(request: { path: string; version: number; after?: number }) { |
| 522 | const startedAt = request.after ?? Date.now() |
| 523 | const pushWait = waitForFreshPush({ |
| 524 | path: request.path, |
| 525 | version: request.version, |
| 526 | after: startedAt, |
| 527 | timeout: DIAGNOSTICS_FULL_WAIT_TIMEOUT_MS, |
| 528 | }) |
| 529 | |
| 530 | while (Date.now() - startedAt < DIAGNOSTICS_FULL_WAIT_TIMEOUT_MS) { |
| 531 | const result = await requestFullDiagnostics(request.path) |
| 532 | if (result.handled || result.matched) return |
| 533 | const remaining = DIAGNOSTICS_FULL_WAIT_TIMEOUT_MS - (Date.now() - startedAt) |
| 534 | if (remaining <= 0) return |
| 535 | const next = await Promise.race([ |
| 536 | pushWait.then((ready) => (ready ? "push" : ("timeout" as const))), |
| 537 | waitForRegistrationChange(remaining).then((changed) => (changed ? "registration" : ("timeout" as const))), |
| 538 | ]) |
| 539 | if (next !== "registration") return |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | // --- Public API --- |
| 544 |
no test coverage detected