Increase ML backend stats timeout and add detailed error logging

Extend timeout for fetching ML backend stats from 5 to 15 seconds and add detailed error logging to the /api/ml/stats endpoint to diagnose potential issues.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 67dbf601-ef19-4ba2-8e69-77f75ec2c104
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/MmMtYN7
This commit is contained in:
marco370 2026-02-16 11:54:00 +00:00
parent d901f264cd
commit 7498527667

View File

@ -719,7 +719,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
app.get("/api/ml/stats", async (req, res) => {
try {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 5000);
const timeout = setTimeout(() => controller.abort(), 15000);
const response = await fetch(`${ML_BACKEND_URL}/stats`, {
headers: getMLBackendHeaders(),
@ -735,6 +735,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
const data = await response.json();
res.json(data);
} catch (error: any) {
console.warn(`[ML Stats] Fallback to database - ML Backend error: ${error.message || error.code || 'unknown'}`);
try {
const latestTraining = await db
.select()