fix: inspect_page 폴링에서 404 응답을 재시도하도록 수정
검사 시작 직후 결과가 아직 DB에 저장되기 전 404가 반환되면 폴링을 계속하도록 에러 핸들링 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@ -13,17 +13,25 @@ export async function inspectPage(
|
|||||||
// 1. Start inspection
|
// 1. Start inspection
|
||||||
const { inspection_id } = await client.startInspection(url, standard);
|
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;
|
let result: InspectionResult | null = null;
|
||||||
for (let i = 0; i < MAX_POLLS; i++) {
|
for (let i = 0; i < MAX_POLLS; i++) {
|
||||||
await sleep(POLL_INTERVAL);
|
await sleep(POLL_INTERVAL);
|
||||||
const data = await client.getInspection(inspection_id);
|
try {
|
||||||
if (data.status === "completed") {
|
const data = await client.getInspection(inspection_id);
|
||||||
result = data;
|
if (data.status === "completed") {
|
||||||
break;
|
result = data;
|
||||||
}
|
break;
|
||||||
if (data.status === "error") {
|
}
|
||||||
throw new Error(`Inspection failed for ${url}`);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user