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
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
feat(tokenHealthCheck): add request coalescing to shouldHideLogs
nyatoruf0a0c97b5ec8
diff --git a/src/lib/tokenHealthCheck.ts b/src/lib/tokenHealthCheck.tsindex 0a2ac7dfa4..bbe933ada5 100644--- a/src/lib/tokenHealthCheck.ts+++ b/src/lib/tokenHealthCheck.ts@@ -25,21 +25,37 @@ const LOG_PREFIX = "[HealthCheck]";// ── Logging helper ───────────────────────────────────────────────────────────let cachedHideLogs: boolean | null = null;let cacheTimestamp = 0;+let pendingHideLogs: Promise<boolean> | null = null;const CACHE_TTL = 30_000; // Cache settings for 30 secondsasync function shouldHideLogs(): Promise<boolean> {const now = Date.now();++ // Return cached value if validif (cachedHideLogs !== null && now - cacheTimestamp < CACHE_TTL) {return cachedHideLogs;}- try {- const settings = await getSettings();- cachedHideLogs = settings.hideHealthCheckLogs === true;- cacheTimestamp = now;- return cachedHideLogs;- } catch {- return false;++ // Return pending promise if a query is already in progress (request coalescing)+ if (pendingHideLogs !== null) {+ return pendingHideLogs;}++ // Create new promise for DB query+ pendingHideLogs = (async () => {+ try {+ const settings = await getSettings();+ cachedHideLogs = settings.hideHealthCheckLogs === true;+ cacheTimestamp = now;+ return cachedHideLogs;+ } catch {+ return false;+ } finally {+ pendingHideLogs = null;+ }+ })();++ return pendingHideLogs;}function log(message: string, ...args: any[]) {