From 49e8731e7f3e90bb1aa9905377005436131f8e61 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 15 Feb 2026 23:06:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DAOS=E6=8A=A0=E5=9B=BE?= =?UTF-8?q?=E8=BD=AE=E8=AF=A2=E7=8A=B6=E6=80=81=E5=88=A4=E6=96=AD=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=AF=BC=E8=87=B4=E8=AF=AF=E5=88=A4=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/rmbg/route.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/api/rmbg/route.ts b/app/api/rmbg/route.ts index 840c6b8c8..42ffe549c 100644 --- a/app/api/rmbg/route.ts +++ b/app/api/rmbg/route.ts @@ -309,6 +309,12 @@ async function processWithAosSegmentation( const state = Number(pollPayload.data.state); const imageUrl = pollPayload.data.image as string | undefined; + const stateDetail = String(pollPayload.data.state_detail || ""); + const errMessage = String(pollPayload.data.err_message || pollPayload.data.err_info || ""); + + if (pollCount === 0 || pollCount % 5 === 0) { + console.log(`[AOS RMBG] poll=${pollCount + 1} state=${state} detail=${stateDetail}`); + } if (state === 1 && imageUrl) { const imageResponse = await withTimeout( @@ -335,10 +341,11 @@ async function processWithAosSegmentation( }; } - if (state === 2 || state === 3 || state === -1) { + // AOS: state=2(Preparing) 属于处理中,不能当失败;只有负数状态视为失败 + if (state < 0) { return { success: false, - error: `AOS任务失败: ${pollPayload?.message || "状态异常"}`, + error: `AOS任务失败: ${errMessage || stateDetail || pollPayload?.message || "状态异常"}`, }; } }