debug(api): log fetch lifecycle for all missions API calls
ci / gates (push) Successful in 5s
ci / frontend (push) Successful in 26s
ci / rust (push) Successful in 4m24s
ci / e2e (push) Skipped
ci / publish (push) Successful in 35s

Adds [api] arrow logs on entry, resolve, and error paths so we can
see in devtools console EXACTLY which endpoint hangs and for how long.
This commit is contained in:
Omar Sobh
2026-07-22 00:54:39 -07:00
parent d207c2c043
commit 827b829993
+19 -7
View File
@@ -181,13 +181,25 @@ async function api<T>(path: string, init?: RequestInit): Promise<T> {
const method = init?.method ?? "GET"; const method = init?.method ?? "GET";
const busted = const busted =
method === "GET" ? `${path}${path.includes("?") ? "&" : "?"}_t=${Date.now()}` : path; method === "GET" ? `${path}${path.includes("?") ? "&" : "?"}_t=${Date.now()}` : path;
const r = await fetch(busted, { const t0 = Date.now();
...init, // eslint-disable-next-line no-console
headers: { console.log(`[api] → ${method} ${busted}`);
"Content-Type": "application/json", let r: Response;
...(init?.headers ?? {}), try {
}, r = await fetch(busted, {
}); ...init,
headers: {
"Content-Type": "application/json",
...(init?.headers ?? {}),
},
});
} catch (e) {
// eslint-disable-next-line no-console
console.error(`[api] ✗ ${method} ${busted} (${Date.now() - t0}ms):`, e);
throw e;
}
// eslint-disable-next-line no-console
console.log(`[api] ← ${method} ${busted} (${Date.now() - t0}ms) status=${r.status}`);
if (!r.ok) { if (!r.ok) {
const text = await r.text().catch(() => ""); const text = await r.text().catch(() => "");
throw new Error(`${init?.method ?? "GET"} ${path} → ${r.status} ${text}`); throw new Error(`${init?.method ?? "GET"} ${path} → ${r.status} ${text}`);