fix: inspect_page 폴링에서 404 응답을 재시도하도록 수정
검사 시작 직후 결과가 아직 DB에 저장되기 전 404가 반환되면 폴링을 계속하도록 에러 핸들링 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@ -13,10 +13,11 @@ 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);
|
||||
try {
|
||||
const data = await client.getInspection(inspection_id);
|
||||
if (data.status === "completed") {
|
||||
result = data;
|
||||
@ -25,6 +26,13 @@ export async function inspectPage(
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Timeout — return partial info
|
||||
|
||||
Reference in New Issue
Block a user