Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix(rate-limit): wire auto-enabled limiters through getLimiter so heartbeat is registered

payne04201b2601853488
diff --git a/open-sse/services/rateLimitManager.ts b/open-sse/services/rateLimitManager.ts
index ef3188eeae..aa52ace948 100644
--- a/open-sse/services/rateLimitManager.ts
+++ b/open-sse/services/rateLimitManager.ts
@@ -148,16 +148,10 @@ function reconcileEnabledConnections(
nextEnabledConnections.add(connectionId);
autoCount++;
- const key = `${provider}:${connectionId}`;
- if (!limiters.has(key)) {
- limiters.set(
- key,
- new Bottleneck({
- ...buildLimiterDefaults(),
- id: key,
- })
- );
- }
+ // Route through getLimiter so the `queued`/`executing` listeners and
+ // lastDispatchAt heartbeat are wired up — otherwise the watchdog sees
+ // `stalledMs = now - 0` and falsely flags healthy idle limiters as wedged.
+ getLimiter(provider, connectionId);
}
}
@@ -183,7 +177,13 @@ function watchdogTick() {
const counts = limiter.counts();
if (counts.QUEUED === 0) continue;
if (counts.RUNNING > 0 || counts.EXECUTING > 0) continue;
- const lastDispatch = lastDispatchAt.get(key) ?? 0;
+ const lastDispatch = lastDispatchAt.get(key);
+ // No heartbeat yet → seed it and skip this tick. Prevents false wedge
+ // detection on a brand-new limiter or one created outside getLimiter.
+ if (lastDispatch === undefined) {
+ lastDispatchAt.set(key, now);
+ continue;
+ }
const stalledMs = now - lastDispatch;
if (stalledMs < WEDGE_THRESHOLD_MS) continue;