fix(awooop): keep work items telemetry from blocking
This commit is contained in:
@@ -98,13 +98,20 @@ const statusConfig: Record<WorkStatus, { className: string; icon: typeof Activit
|
||||
},
|
||||
};
|
||||
|
||||
async function fetchJson<T>(url: string): Promise<T | null> {
|
||||
async function fetchJson<T>(url: string, timeoutMs = 8000): Promise<T | null> {
|
||||
const controller = new AbortController();
|
||||
const timeout = window.setTimeout(() => controller.abort(), timeoutMs);
|
||||
try {
|
||||
const response = await fetch(url, { cache: "no-store" });
|
||||
const response = await fetch(url, {
|
||||
cache: "no-store",
|
||||
signal: controller.signal,
|
||||
});
|
||||
if (!response.ok) return null;
|
||||
return (await response.json()) as T;
|
||||
} catch {
|
||||
return null;
|
||||
} finally {
|
||||
window.clearTimeout(timeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user