fix: add timeout handling and debug logs for scene fusion
This commit is contained in:
parent
0333f1953e
commit
c0b1081c81
@ -182,12 +182,19 @@ export function SceneFusionView({ onBack }: SceneFusionViewProps) {
|
|||||||
));
|
));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
console.log('[SceneFusion Client] Starting API call with', scenesToProcess.length, 'scenes');
|
||||||
|
|
||||||
|
// 创建 AbortController 用于超时控制(10分钟)
|
||||||
|
const controller = new AbortController();
|
||||||
|
const timeoutId = setTimeout(() => controller.abort(), 10 * 60 * 1000);
|
||||||
|
|
||||||
// 调用后端 API
|
// 调用后端 API
|
||||||
const response = await fetch('/api/scene-fusion', {
|
const response = await fetch('/api/scene-fusion', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
|
signal: controller.signal,
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
productImage,
|
productImage,
|
||||||
productName: productName || undefined, // 产品名称
|
productName: productName || undefined, // 产品名称
|
||||||
@ -201,17 +208,23 @@ export function SceneFusionView({ onBack }: SceneFusionViewProps) {
|
|||||||
})),
|
})),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
console.log('[SceneFusion Client] Response received, status:', response.status);
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
console.log('[SceneFusion Client] Response data:', JSON.stringify(data).substring(0, 500));
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(data.error || '处理失败');
|
throw new Error(data.error || '处理失败');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新场景状态
|
// 更新场景状态
|
||||||
|
console.log('[SceneFusion Client] Updating scenes with results:', data.results?.length);
|
||||||
setScenes(prev => prev.map(s => {
|
setScenes(prev => prev.map(s => {
|
||||||
const result = data.results?.find((r: any) => r.id === s.id);
|
const result = data.results?.find((r: any) => r.id === s.id);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
console.log('[SceneFusion Client] Scene', s.id, 'result:', result.status);
|
||||||
if (result.status === 'completed') {
|
if (result.status === 'completed') {
|
||||||
return {
|
return {
|
||||||
...s,
|
...s,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user