From 3963575529c2368bd37b1561126aa076de30b0b3 Mon Sep 17 00:00:00 2001 From: payne0420 Date: Thu, 30 Apr 2026 17:30:05 +0000 Subject: [PATCH] fix(rate-limit): raise wedge threshold from 5s to 120s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses gemini-code-assist review on #1828: at 5s, the watchdog can false-trigger on a healthy limiter that's correctly waiting on its reservoir refresh (60s default) or adaptive minTime (up to ~60s for 1-RPM providers). 120s gives a 2× margin against both while still catching the actual wedge case (observed at 3+ minutes stalled). Co-Authored-By: Claude Opus 4.7 (1M context) --- open-sse/services/rateLimitManager.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/open-sse/services/rateLimitManager.ts b/open-sse/services/rateLimitManager.ts index aeda709122..ef3188eeae 100644 --- a/open-sse/services/rateLimitManager.ts +++ b/open-sse/services/rateLimitManager.ts @@ -74,7 +74,12 @@ let currentRequestQueueSettings: RequestQueueSettings = DEFAULT_RESILIENCE_SETTI const lastDispatchAt = new Map(); let watchdogInterval: ReturnType | null = null; const WATCHDOG_INTERVAL_MS = 30_000; -const WEDGE_THRESHOLD_MS = 5_000; +// Threshold has to exceed any *legitimate* gap between dispatches: +// - default reservoirRefreshInterval is 60s +// - adaptive minTime can climb to ~60s for 1-RPM providers (see updateFromHeaders) +// 120s gives a 2× margin against both, while still catching the actual wedge +// case we observed (queue stalled for 3+ minutes with no progress). +const WEDGE_THRESHOLD_MS = 120_000; /** * Env-var override for the auto-enable safety net. Highest priority — wins