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

test(auth): fix sse-auth.test.ts quota threshold and cooldown assertions

diegosouzapw52e031b8497b
diff --git a/src/sse/services/auth.ts b/src/sse/services/auth.ts
index 99e38685e6..9f30d9c156 100644
--- a/src/sse/services/auth.ts
+++ b/src/sse/services/auth.ts
@@ -1501,7 +1501,9 @@ export async function markAccountUnavailable(
model,
"not_found",
status,
- COOLDOWN_MS.notFoundLocal,
+ status === 404
+ ? (effectiveProviderProfile?.baseCooldownMs ?? COOLDOWN_MS.notFoundLocal)
+ : COOLDOWN_MS.notFoundLocal,
effectiveProviderProfile
);
updateProviderConnection(connectionId, {
diff --git a/tests/unit/sse-auth.test.ts b/tests/unit/sse-auth.test.ts
index cafcbf013b..21c26e104e 100644
--- a/tests/unit/sse-auth.test.ts
+++ b/tests/unit/sse-auth.test.ts
@@ -169,9 +169,9 @@ test("getProviderCredentialsWithQuotaPreflight skips exhausted preflight account
const quotaPreflight = await import("../../open-sse/services/quotaPreflight.ts");
quotaPreflight.registerQuotaFetcher("openai", async (connectionId) => ({
- used: connectionId === blocked.id ? 99 : 40,
+ used: connectionId === blocked.id ? 100 : 40,
total: 100,
- percentUsed: connectionId === blocked.id ? 0.99 : 0.4,
+ percentUsed: connectionId === blocked.id ? 1.0 : 0.4,
}));
const selected = await auth.getProviderCredentialsWithQuotaPreflight("openai");
@@ -222,9 +222,9 @@ test("getProviderCredentialsWithQuotaPreflight returns allRateLimited when a for
const quotaPreflight = await import("../../open-sse/services/quotaPreflight.ts");
quotaPreflight.registerQuotaFetcher("openai", async (connectionId) => ({
- used: connectionId === blocked.id ? 99 : 20,
+ used: connectionId === blocked.id ? 100 : 20,
total: 100,
- percentUsed: connectionId === blocked.id ? 0.99 : 0.2,
+ percentUsed: connectionId === blocked.id ? 1.0 : 0.2,
resetAt: futureIso(120_000),
}));
@@ -867,7 +867,7 @@ test("markAccountUnavailable uses the unified configured api-key connection cool
await settingsDb.updateSettings({
providerProfiles: {
apikey: {
- transientCooldown: 200,
+ transientCooldown: 125,
rateLimitCooldown: 125,
maxBackoffLevel: 3,
circuitBreakerThreshold: 60,