fix: add HTTP polling fallback for selenium job results through Cloudflare
Socket.IO reconnects through Cloudflare proxy get a new socket.id, causing the backend to emit job:update to a stale socket that no longer exists. The PDF viewer modal never opened even though PDFs were saved successfully. Adds a GET /api/insurance-status/job-status/:jobId endpoint backed by InProcessQueue.getJob(), and a waitForSeleniumJob() helper on the frontend that races socket events against HTTP polling every 3s. Whichever resolves first wins, so local (socket) and external (Cloudflare) both work reliably. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -196,6 +196,13 @@ export function enqueueSeleniumJob(data: SeleniumJobData): string {
|
||||
return jobId;
|
||||
}
|
||||
|
||||
// ── Job status query (HTTP polling fallback) ─────────────────────────────────
|
||||
export function getSeleniumJobStatus(jobId: string) {
|
||||
const job = seleniumQ.getJob(jobId);
|
||||
if (!job) return null;
|
||||
return { status: job.status, result: job.result ?? null, error: job.error ?? null };
|
||||
}
|
||||
|
||||
// ── OCR enqueue ──────────────────────────────────────────────────────────────
|
||||
export function enqueueOcrJob(data: OcrJobData): string {
|
||||
const { socketId } = data;
|
||||
|
||||
Reference in New Issue
Block a user