Merge pull request #982 from Molecule-AI/fix/canvas-api-fetch-timeout

fix(canvas): add 15s fetch timeout on API calls
This commit is contained in:
Hongming Wang 2026-04-19 03:27:09 -07:00 committed by GitHub
commit 3e448c2569
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,6 +8,12 @@ import { getTenantSlug } from "./tenant";
export const PLATFORM_URL =
process.env.NEXT_PUBLIC_PLATFORM_URL ?? "http://localhost:8080";
// 15s is long enough for slow CP queries but short enough that a
// hung backend doesn't leave the UI spinning forever. The abort
// propagates through AbortController so React components can observe
// the error and render a retry affordance.
const DEFAULT_TIMEOUT_MS = 15_000;
async function request<T>(
method: string,
path: string,
@ -28,6 +34,7 @@ async function request<T>(
headers,
body: body ? JSON.stringify(body) : undefined,
credentials: "include",
signal: AbortSignal.timeout(DEFAULT_TIMEOUT_MS),
});
if (!res.ok) {
const text = await res.text();