feat: enhance disconnect handling and request tracking in chatCore.js (#126)

Co-authored-by: zx <me@char.moe>
This commit is contained in:
zx07
2026-02-15 12:51:37 +08:00
committed by GitHub
parent ac7cedd27e
commit 3d29b86d44
2 changed files with 19 additions and 2 deletions

View File

@@ -417,7 +417,20 @@ export async function handleChatCore({ body, modelInfo, credentials, log, onCred
log?.debug?.("REQUEST", `${provider.toUpperCase()} | ${model} | ${msgCount} msgs`);
// Create stream controller for disconnect detection
const streamController = createStreamController({ onDisconnect, log, provider, model });
const streamController = createStreamController({
onDisconnect: (reason) => {
// Track request finished (disconnected)
trackPendingRequest(model, provider, connectionId, false);
if (onDisconnect) onDisconnect(reason);
},
onError: (error) => {
// Track request finished (error/zombie)
trackPendingRequest(model, provider, connectionId, false);
},
log,
provider,
model
});
// Execute request using executor (handles URL building, headers, fallback, transform)
let providerResponse;