fix(rate-limit): raise wedge threshold from 5s to 120s

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) <noreply@anthropic.com>
This commit is contained in:
payne0420
2026-04-30 17:30:05 +00:00
parent 294751d8a3
commit 3963575529

View File

@@ -74,7 +74,12 @@ let currentRequestQueueSettings: RequestQueueSettings = DEFAULT_RESILIENCE_SETTI
const lastDispatchAt = new Map<string, number>();
let watchdogInterval: ReturnType<typeof setInterval> | 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