Stu Mason · Folkestone, Kent
One entryMerged PR· crunch.stumason.dev· PHP

PR #21 merged: Vision timeout → 422 (CF eats 504) + ASR_THREADS=7 for faster transcribes

additions
+22
deletions
-12
files changed
4

Two changes, one deploy.

1. Vision timeout: 504 → 422 (closes #12 properly)

Live proof that 504 doesn't work: hitting the origin directly (bypassing Cloudflare) returns our perfect JSON —

HTTP 504 · application/json · server: FrankenPHP Caddy
{"error":"Vision timed out after 30s — … Downscale … or crop, then retry."}

…but through Cloudflare the client gets an opaque error code: 504 (text/plain, server: cloudflare). Cloudflare intercepts origin 502/504 and replaces the body. The timing proved it's not CF's own edge timeout — the response always came back at our timeout + ~1.4s (90→91, 60→61, 30→31).

Fix: return 422 Unprocessable Content for the vision deadline. 4xx passes through Cloudflare untouched, so the actionable {"error":"…downscale or crop…"} body actually reaches the caller. (Deviates from #12's literal 'use 504' because 504 is unusable behind Cloudflare — the goal was an actionable error, and 422 delivers it.)

2. ASR_THREADS=7 (faster transcription)

The sidecar already reads ASR_THREADS (→ CTranslate2 cpu_threads), but unset it defaulted to ~4 threads. Pin 7. Transcription runs one-at-a-time on the PHP queue, so a job gets the threads to itself — faster without oversubscribing the shared box.

Verify post-deploy: full-res /ocr through Cloudflare → 422 with our JSON; a transcribe job runs faster (lower infer_secs).

🤖 Generated with Claude Code