fix(qoder): increase timeouts for reasoning models and improve stream handling

This commit is contained in:
decolua
2026-06-08 09:17:33 +07:00
parent 51cbe65c15
commit 137a25e9ac
4 changed files with 21 additions and 8 deletions

View File

@@ -28,6 +28,7 @@ import { createHash } from "crypto";
import { BaseExecutor } from "./base.js";
import { PROVIDERS } from "../config/providers.js";
import { proxyAwareFetch } from "../utils/proxyFetch.js";
import { FETCH_CONNECT_TIMEOUT_MS } from "../config/runtimeConfig.js";
import {
QODER_CHAT_URL_ENCODED,
QODER_MODEL_MAP,
@@ -407,15 +408,21 @@ export class QoderExecutor extends BaseExecutor {
...cosyHeaders,
};
// Abort if upstream doesn't return response headers within connect timeout.
const timeoutMs = this.config?.timeoutMs || FETCH_CONNECT_TIMEOUT_MS;
const connectCtrl = new AbortController();
const connectTimer = setTimeout(() => connectCtrl.abort(new Error("fetch connect timeout")), timeoutMs);
const mergedSignal = signal ? AbortSignal.any([signal, connectCtrl.signal]) : connectCtrl.signal;
let response;
try {
response = await proxyAwareFetch(
url,
{ method: "POST", headers, body: encodedBodyBuf, signal },
{ method: "POST", headers, body: encodedBodyBuf, signal: mergedSignal },
proxyOptions,
);
} catch (err) {
throw err;
} finally {
clearTimeout(connectTimer);
}
if (!response.ok) {