Repository navigation
fix(behavioral-checker): time out OpenAI calls before Vercel kills /api/analysis - #65
Merged
Merged
Conversation
…pi/analysis Whisper and gpt-4o calls had no timeout (SDK default 10 min), so a slow call ran into Vercel's 30s limit and left only a bare 504 with no route log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The OpenAI clients had no timeout (the SDK defaults to 10 min). A slow call ran into Vercel's 30s limit, the function was frozen, and the route log never ran. All we got was a bare 504.
new OpenAI({ apiKey, + timeout: OPENAI_TIMEOUT_MS, // 20s + maxRetries: OPENAI_MAX_RETRIES, // 1 }) export const config = { + maxDuration: 120, // worst case ≈ 2×(2×20s) + Notion 3×5s ≈ 95s api: { bodyParser: false }, }Evidence
Duration: 30022 msplusTask timed out after 30 seconds, and no/api/analysisroute log line.After: OpenAI client pointed at a server that never responds (timeout 500ms, 1 retry). It throws, and the route log line comes out:
bun tscclean,bun run test195/195 passing.Merge Danger
Door: two-way
Blast Radius: behavioral-checker
Only
/api/analysisuses these clients. A call that would previously have finished after 20s now fails with a 500. Normal calls take 1–5s.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.