mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-01 12:52:11 +03:00
* fix: add AbortController timeout to fetchImageEndpoint fetchImageEndpoint uses raw fetch() without timeout control. Long-running image generation requests (~20-30s) are killed by Next.js default timeout, producing upstream_error responses. Replace fetch() with fetchWithTimeout() from shared utils, defaulting to FETCH_TIMEOUT_MS (120s via OMNIROUTE_DEFAULT_FETCH_TIMEOUT_MS). * fix: return 504 for image fetch timeout, add tests Address review feedback from gemini-code-assist: - Import FetchTimeoutError and catch it in fetchImageEndpoint - Return 504 (Gateway Timeout) instead of 502 for timeout/AbortError - Add 3 focused unit tests for timeout, non-timeout, and success paths Clarifies timeout semantics: timeout is a gateway timeout (504), not a bad gateway (502). Non-timeout fetch errors remain 502. --------- Co-authored-by: mgarmash <mgarmash@37bytes.com>