diff --git a/mcp/src/tools/inspect-page.ts b/mcp/src/tools/inspect-page.ts index 5b45e60..2d2f928 100644 --- a/mcp/src/tools/inspect-page.ts +++ b/mcp/src/tools/inspect-page.ts @@ -13,17 +13,25 @@ export async function inspectPage( // 1. Start inspection const { inspection_id } = await client.startInspection(url, standard); - // 2. Poll until completion + // 2. Poll until completion (404 = not yet saved, keep polling) let result: InspectionResult | null = null; for (let i = 0; i < MAX_POLLS; i++) { await sleep(POLL_INTERVAL); - const data = await client.getInspection(inspection_id); - if (data.status === "completed") { - result = data; - break; - } - if (data.status === "error") { - throw new Error(`Inspection failed for ${url}`); + try { + const data = await client.getInspection(inspection_id); + if (data.status === "completed") { + result = data; + break; + } + if (data.status === "error") { + throw new Error(`Inspection failed for ${url}`); + } + } catch (err) { + // 404 or transient error — keep polling + if (err instanceof Error && err.message.includes("failed")) { + continue; + } + throw err; } }