fix: tolerate transient style pro task polling failures
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-05-22 21:23:20 +08:00
parent 4aead3018f
commit b58e0f945e

View File

@ -1331,10 +1331,18 @@ export function StyleProWorkspace({
while (Date.now() < deadline) { while (Date.now() < deadline) {
await sleep(STYLE_PRO_TASK_POLL_INTERVAL_MS); await sleep(STYLE_PRO_TASK_POLL_INTERVAL_MS);
const statusResponse = await fetch( let statusResponse: Response;
`/api/style-pro/generate?taskId=${encodeURIComponent(taskId)}`, try {
{ cache: "no-store" } statusResponse = await fetch(
); `/api/style-pro/generate?taskId=${encodeURIComponent(taskId)}`,
{ cache: "no-store" }
);
} catch (pollError) {
lastError =
pollError instanceof Error ? pollError.message : "查询任务失败";
continue;
}
const statusPayload = (await statusResponse.json().catch(() => ({}))) as const statusPayload = (await statusResponse.json().catch(() => ({}))) as
| StyleProGenerateResponse | StyleProGenerateResponse
| undefined; | undefined;