* Wait for the viewer's first poll_pdf_commands call. * * Called before waitForPageData() / waitForSaveData() so a viewer that never * mounted fails in ~8s with a specific message instead of a generic 45s * "Timeout waiting for ..." that gives no hint why. * * Intentionally does NOT touch poll
(uuid: string)
| 262 | * can wait independently and all observe the same add() when it happens. |
| 263 | */ |
| 264 | async function ensureViewerIsPolling(uuid: string): Promise<void> { |
| 265 | const deadline = Date.now() + VIEWER_FIRST_POLL_GRACE_MS; |
| 266 | while (!viewsPolled.has(uuid)) { |
| 267 | if (Date.now() >= deadline) { |
| 268 | throw new Error( |
| 269 | `Viewer never connected for viewUUID ${uuid} (no poll within ${VIEWER_FIRST_POLL_GRACE_MS / 1000}s). ` + |
| 270 | `The iframe likely failed to mount — this happens when the conversation ` + |
| 271 | `goes idle before the viewer finishes loading. Call display_pdf again to get a fresh viewUUID.`, |
| 272 | ); |
| 273 | } |
| 274 | await new Promise((r) => setTimeout(r, 100)); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | // ============================================================================= |
| 279 | // Pending save_as Requests (request-response bridge via client) |
no outgoing calls
no test coverage detected
searching dependent graphs…