修复AOS抠图轮询状态判断错误导致误判失败
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-02-15 23:06:18 +08:00
parent 2987bd793e
commit 49e8731e7f

View File

@ -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 || "状态异常"}`,
};
}
}