Skip to content

fix(behavioral-checker): time out OpenAI calls before Vercel kills /api/analysis - #65

Merged
lautaropaske merged 1 commit into
mainfrom
fix/analysis-timeouts
Nov 4, 2026
Merged

lautaropaske merged 1 commit into
mainfrom
fix/analysis-timeouts

Conversation

@lautaropaske

@lautaropaske lautaropaske commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Before: three 504s on Nov 3 between 17:32 and 17:38 UTC, each Duration: 30022 ms plus Task timed out after 30 seconds, and no /api/analysis route 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:
    {"http.route":"/api/analysis","outcome":"error","phase":"transcribe","durationsMs":{"transcribe":1399},"error":{"message":"Request timed out."...}}
    
  • bun tsc clean, bun run test 195/195 passing.

Merge Danger

Door: two-way

Blast Radius: behavioral-checker

Only /api/analysis uses 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


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…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>
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
open-silver Ready Ready Preview Nov 3, 2026 8:30pm UTC

Request Review

@lautaropaske
lautaropaske merged commit 1cd559d into main Nov 4, 2026
7 checks passed
@lautaropaske
lautaropaske deleted the fix/analysis-timeouts branch November 4, 2026 15:11

This branch was successfully deployed

1 active deployment
Preview — 9fe68617 Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant