mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-04 22:32:12 +03:00
Under concurrent load, requests exceeding the per-connection rate-limit queue budget (resilienceSettings.requestQueue.maxWaitMs) are dropped by Bottleneck with its raw 'This job timed out after <maxWaitMs> ms.' message. That string is indistinguishable from an upstream gateway timeout, so the 502 body and call-log last_error masquerade as a provider outage across unrelated providers (TI:0|TO:0) — the #4165 reporter spent ~3h misdiagnosing local queue saturation as upstream failures. withRateLimit now rewrites that specific Bottleneck error into a clear, OmniRoute-owned message: names the knob (requestQueue.maxWaitMs, Settings → Resilience), disclaims an upstream timeout, preserves the original as cause, and tags code=RATE_LIMIT_QUEUE_TIMEOUT. Behavior unchanged — the job is still dropped so combo falls back. TDD: tests/unit/rate-limit-queue-timeout-message-4165.test.ts drives a real Bottleneck expiration (tiny maxWaitMs + a slow job) and asserts the surfaced error carries the code + clear message and no longer leaks 'This job timed out' (RED 1/2 -> GREEN 2/2). Rebaselined rateLimitManager.ts 1022->1035 at the existing catch chokepoint.