Add 30s timeout to OpenAI API call in /api/generate #1280

Open
opened 2026-04-13 11:17:35 -04:00 by pook · 0 comments
Owner

Wrap the OpenAI API call in /api/generate with a 30-second timeout to prevent hung requests from consuming server resources.

Implementation:

  1. Locate the OpenAI call in the /api/generate handler
  2. Use AbortController with a 30s setTimeout to enforce the timeout
  3. On timeout, return 504 Gateway Timeout with a user-friendly message: 'Document generation is taking too long. Please try again.'
  4. Add a unit test verifying the timeout fires correctly
  5. Ensure the AbortController is cleaned up on successful completion

This prevents resource exhaustion from slow or hung OpenAI responses.

Acceptance criteria: OpenAI calls timeout after 30s, 504 returned, test passes, build clean.


Generated by CEO Planner (priority: 3)

Wrap the OpenAI API call in /api/generate with a 30-second timeout to prevent hung requests from consuming server resources. Implementation: 1. Locate the OpenAI call in the /api/generate handler 2. Use AbortController with a 30s setTimeout to enforce the timeout 3. On timeout, return 504 Gateway Timeout with a user-friendly message: 'Document generation is taking too long. Please try again.' 4. Add a unit test verifying the timeout fires correctly 5. Ensure the AbortController is cleaned up on successful completion This prevents resource exhaustion from slow or hung OpenAI responses. Acceptance criteria: OpenAI calls timeout after 30s, 504 returned, test passes, build clean. --- *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#1280
No description provided.