-
Notifications
You must be signed in to change notification settings - Fork 73
Description
Problem
All frontend Next.js API proxy routes (under components/frontend/src/app/api/) call fetch() to proxy requests to the backend without any timeout configured. If the backend is unresponsive, these requests can hang indefinitely, blocking the Next.js server handler and degrading the user experience.
There are approximately 85+ route files affected (e.g. cluster-info/route.ts, version/route.ts, projects/route.ts, and many more).
Proposed Solution
Add a consistent timeout mechanism across all proxy routes. Options include:
- Use
AbortControllerwithsetTimeoutand passsignaltofetch(), returning a504response on abort. - Extract a shared
fetchWithTimeoututility (e.g. incomponents/frontend/src/lib/) to keep the implementation DRY and consistent across all routes. - Decide on a sensible default timeout (e.g. 10–30 seconds) appropriate for the backend SLAs.
The catch block in each route should distinguish AbortError (timeout → 504) from other errors (→ 500).
Context
Identified during review of PR #998 (comment: #998 (comment)). Adding a timeout to only version/route.ts in isolation was intentionally deferred to keep that PR focused; a follow-up addressing all routes consistently is the right approach.
Requested by @ktdreyer.