mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
Fix bug
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { getProviderConnections, validateApiKey, updateProviderConnection, getSettings } from "@/lib/localDb";
|
||||
import { resolveConnectionProxyConfig } from "@/lib/network/connectionProxy";
|
||||
import { formatRetryAfter, checkFallbackError, isModelLockActive, buildModelLockUpdate, getEarliestModelLockUntil } from "open-sse/services/accountFallback.js";
|
||||
import { resolveProviderId } from "@/shared/constants/providers.js";
|
||||
import { resolveProviderId, FREE_PROVIDERS } from "@/shared/constants/providers.js";
|
||||
import * as log from "../utils/logger.js";
|
||||
|
||||
// Mutex to prevent race conditions during account selection
|
||||
@@ -30,6 +30,11 @@ export async function getProviderCredentials(provider, excludeConnectionIds = nu
|
||||
// Resolve alias to provider ID (e.g., "kc" -> "kilocode")
|
||||
const providerId = resolveProviderId(provider);
|
||||
|
||||
// Inject a virtual connection for no-auth free providers
|
||||
if (FREE_PROVIDERS[providerId]?.noAuth) {
|
||||
return { id: "noauth", connectionName: "Public", isActive: true, accessToken: "public" };
|
||||
}
|
||||
|
||||
const connections = await getProviderConnections({ provider: providerId, isActive: true });
|
||||
log.debug("AUTH", `${provider} | total connections: ${connections.length}, excludeIds: ${excludeSet.size > 0 ? [...excludeSet].join(",") : "none"}, model: ${model || "any"}`);
|
||||
|
||||
@@ -164,6 +169,7 @@ export async function getProviderCredentials(provider, excludeConnectionIds = nu
|
||||
* @returns {{ shouldFallback: boolean, cooldownMs: number }}
|
||||
*/
|
||||
export async function markAccountUnavailable(connectionId, status, errorText, provider = null, model = null) {
|
||||
if (!connectionId || connectionId === "noauth") return { shouldFallback: false, cooldownMs: 0 };
|
||||
const connections = await getProviderConnections({ provider });
|
||||
const conn = connections.find(c => c.id === connectionId);
|
||||
const backoffLevel = conn?.backoffLevel || 0;
|
||||
@@ -204,6 +210,7 @@ export async function markAccountUnavailable(connectionId, status, errorText, pr
|
||||
* @param {string|null} model - model that succeeded
|
||||
*/
|
||||
export async function clearAccountError(connectionId, currentConnection, model = null) {
|
||||
if (!connectionId || connectionId === "noauth") return;
|
||||
const conn = currentConnection._connection || currentConnection;
|
||||
const now = Date.now();
|
||||
const allLockKeys = Object.keys(conn).filter(k => k.startsWith("modelLock_"));
|
||||
|
||||
Reference in New Issue
Block a user