Fixed IPv6 fetch failure
Browse filesX-Lovable-Edit-ID: edt-1b83492b-ea01-499a-999e-89741e085ada
src/server/incidents.functions.ts
CHANGED
|
@@ -107,14 +107,16 @@ export const analyzeIncident = createServerFn({ method: "POST" })
|
|
| 107 |
body: requestBody,
|
| 108 |
});
|
| 109 |
break;
|
| 110 |
-
} catch (e) {
|
| 111 |
lastErr = e;
|
|
|
|
| 112 |
await new Promise((r) => setTimeout(r, 400 * (attempt + 1)));
|
| 113 |
}
|
| 114 |
}
|
| 115 |
if (!resp) {
|
| 116 |
-
const
|
| 117 |
-
|
|
|
|
| 118 |
}
|
| 119 |
|
| 120 |
if (!resp.ok) {
|
|
|
|
| 107 |
body: requestBody,
|
| 108 |
});
|
| 109 |
break;
|
| 110 |
+
} catch (e: any) {
|
| 111 |
lastErr = e;
|
| 112 |
+
console.error(`[analyzeIncident] fetch attempt ${attempt + 1} failed:`, e?.message, e?.cause?.message, e?.cause?.code);
|
| 113 |
await new Promise((r) => setTimeout(r, 400 * (attempt + 1)));
|
| 114 |
}
|
| 115 |
}
|
| 116 |
if (!resp) {
|
| 117 |
+
const e = lastErr as any;
|
| 118 |
+
const detail = e?.cause?.message || e?.cause?.code || e?.message || String(lastErr);
|
| 119 |
+
throw new Error(`Could not reach AI gateway: ${detail}`);
|
| 120 |
}
|
| 121 |
|
| 122 |
if (!resp.ok) {
|