fix(qoder): increase timeouts for reasoning models and improve stream handling
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user