fix: inspect_page 폴링에서 404 응답을 재시도하도록 수정

검사 시작 직후 결과가 아직 DB에 저장되기 전 404가 반환되면
폴링을 계속하도록 에러 핸들링 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jungwoo choi
2026-02-15 08:45:36 +09:00
parent 6eaef94a78
commit 39ffe879f0

View File

@ -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;
}
}