mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-15 19:28:52 +02:00
fix(ai): implement automatic network retry for OpenRouter 502/503/529 overloads in Bulk Analyzer
This commit is contained in:
1 parent
dd135ee67b
commit
b921f5ad40
3 files changed
+29
-7
No files matched your search
@@ -37,7 +37,15 @@ export async function POST(req: NextRequest) {
|
||||
console.warn(`[AI] Timeout for product analysis — OpenRouter too slow.`);
|
||||
return NextResponse.json({ error: "timeout", retryAfter: 5 }, { status: 504 });
|
||||
}
|
||||
|
||||
const msg = err instanceof Error ? err.message : "Unknown error";
|
||||
|
||||
// Propager l'état de surcharge Open Router (502 Gateway, 503 Unavailable, 529 Overloaded)
|
||||
if (msg.includes("502") || msg.includes("503") || msg.includes("529") || msg.includes("Bad Gateway") || msg.includes("overloaded")) {
|
||||
console.warn(`[AI] External API overload detected: ${msg}`);
|
||||
return NextResponse.json({ error: "gateway_timeout", detail: msg }, { status: 502 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ error: msg }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user