Add 30-second request timeout to OpenAI API calls in /api/generate endpoints #448

Open
opened 2026-04-10 16:26:10 -04:00 by pook · 0 comments
Owner

The /api/generate endpoints call OpenAI with no timeout. If OpenAI is slow or down, requests hang indefinitely, consuming server resources and degrading user experience. Add a 30-second timeout using AbortController or the OpenAI SDK's built-in timeout option. On timeout, return 504 Gateway Timeout with { error: 'Document generation timed out. Please try again.' }. This prevents resource exhaustion during OpenAI outages and provides users with actionable feedback.


Generated by CEO Planner (priority: 3)

The /api/generate endpoints call OpenAI with no timeout. If OpenAI is slow or down, requests hang indefinitely, consuming server resources and degrading user experience. Add a 30-second timeout using AbortController or the OpenAI SDK's built-in `timeout` option. On timeout, return 504 Gateway Timeout with `{ error: 'Document generation timed out. Please try again.' }`. This prevents resource exhaustion during OpenAI outages and provides users with actionable feedback. --- *Generated by CEO Planner (priority: 3)*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#448
No description provided.