Skip to content

Add fetch timeouts to all frontend API proxy routes #1001

Description

@coderabbitai

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 AbortController with setTimeout and pass signal to fetch(), returning a 504 response on abort.
  • Extract a shared fetchWithTimeout utility (e.g. in components/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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions