gpt-engineer-app[bot] commited on
Commit
445e7e9
·
2 Parent(s): 49e5894c2829a0

Fixed IPv6 fetch failure

Browse files

X-Lovable-Edit-ID: edt-1b83492b-ea01-499a-999e-89741e085ada

Files changed (1) hide show
  1. src/server/incidents.functions.ts +5 -3
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 msg = lastErr instanceof Error ? lastErr.message : String(lastErr);
117
- throw new Error(`Could not reach AI gateway: ${msg}`);
 
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) {