From 220f8ea3ac70d03ed256398caa41b737f1135e4b Mon Sep 17 00:00:00 2001 From: Eric Gullickson <16152721+ericgullickson@users.noreply.github.com> Date: Fri, 13 Feb 2026 21:38:05 -0600 Subject: [PATCH] fix: increase hybrid engine cloud timeout for WIF token exchange (refs #182) The 5s cloud timeout was too tight for the initial WIF authentication which requires 3 HTTP round-trips (STS, IAM credentials, resource manager). First call took 5.5s and was discarded, falling back to slow CPU-based PaddleOCR. Increased to 10s to accommodate cold-start auth. Co-Authored-By: Claude Opus 4.6 --- ocr/app/engines/hybrid_engine.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ocr/app/engines/hybrid_engine.py b/ocr/app/engines/hybrid_engine.py index 525a669..4c1c90b 100644 --- a/ocr/app/engines/hybrid_engine.py +++ b/ocr/app/engines/hybrid_engine.py @@ -18,8 +18,11 @@ from app.engines.base_engine import ( logger = logging.getLogger(__name__) -# Maximum time (seconds) to wait for the cloud fallback -_CLOUD_TIMEOUT_SECONDS = 5.0 +# Maximum time (seconds) to wait for the cloud engine. +# WIF token exchange on first call requires 3 HTTP round-trips +# (STS -> IAM credentials -> resource manager) which can take 6-8s. +# Subsequent calls use cached tokens and are fast (<1s). +_CLOUD_TIMEOUT_SECONDS = 10.0 # Redis key prefix for monthly Vision API request counter _VISION_COUNTER_PREFIX = "ocr:vision_requests"