From b58e0f945ea455d159361e3c8ef0013523efe378 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 22 May 2026 21:23:20 +0800 Subject: [PATCH] fix: tolerate transient style pro task polling failures --- components/style-pro/StyleProWorkspace.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/components/style-pro/StyleProWorkspace.tsx b/components/style-pro/StyleProWorkspace.tsx index 19ed44115..866ec7bcb 100644 --- a/components/style-pro/StyleProWorkspace.tsx +++ b/components/style-pro/StyleProWorkspace.tsx @@ -1331,10 +1331,18 @@ export function StyleProWorkspace({ while (Date.now() < deadline) { await sleep(STYLE_PRO_TASK_POLL_INTERVAL_MS); - const statusResponse = await fetch( - `/api/style-pro/generate?taskId=${encodeURIComponent(taskId)}`, - { cache: "no-store" } - ); + let statusResponse: Response; + try { + 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 | StyleProGenerateResponse | undefined;