mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-05 13:55:02 +00:00
fix(openai): narrow timeout fetch contract
This commit is contained in:
parent
e4a9538289
commit
423b1cb41b
3 changed files with 5 additions and 4 deletions
|
|
@ -21,7 +21,7 @@ const HEADER_TIMEOUT = Symbol.for("opencode.provider.header-timeout")
|
|||
const ALLOWED_MODELS = new Set(["gpt-5.5", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini"])
|
||||
|
||||
export function fetchWithHeaderTimeout(
|
||||
fetch: typeof globalThis.fetch,
|
||||
fetch: OpenAIWebSocketPool.Fetch,
|
||||
input: RequestInfo | URL,
|
||||
init: RequestInit | undefined,
|
||||
timeout: number | false,
|
||||
|
|
@ -374,7 +374,7 @@ export async function CodexAuthPlugin(input: PluginInput, options: CodexAuthPlug
|
|||
let httpHeaderTimeout: number | false = DEFAULT_HTTP_HEADER_TIMEOUT
|
||||
let websocketFetchInstalled = false
|
||||
const websocketFetches: Array<ReturnType<typeof OpenAIWebSocketPool.createWebSocketFetch>> = []
|
||||
const httpFetch: typeof globalThis.fetch = (requestInput, init) =>
|
||||
const httpFetch: OpenAIWebSocketPool.Fetch = (requestInput, init) =>
|
||||
fetchWithHeaderTimeout(fetch, requestInput, init, httpHeaderTimeout)
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -5,11 +5,12 @@ import { isRecord } from "@/util/record"
|
|||
import { OpenAIWebSocket } from "./ws"
|
||||
|
||||
export const TITLE_HEADER = "x-opencode-title"
|
||||
export type Fetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>
|
||||
|
||||
const log = Log.create({ service: "plugin.openai.ws" })
|
||||
|
||||
export interface CreateWebSocketFetchOptions {
|
||||
httpFetch?: typeof globalThis.fetch
|
||||
httpFetch?: Fetch
|
||||
url?: string
|
||||
connectTimeout?: number
|
||||
idleTimeout?: number
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ const HEADER_TIMEOUT = Symbol.for("opencode.provider.header-timeout")
|
|||
|
||||
export function headerTimeoutForFetch(fetch: unknown, timeout: number | false | undefined) {
|
||||
if (timeout === false) return undefined
|
||||
if (typeof fetch === "function" && fetch[HEADER_TIMEOUT] === false) return undefined
|
||||
if (typeof fetch === "function" && (fetch as { [HEADER_TIMEOUT]?: false })[HEADER_TIMEOUT] === false) return undefined
|
||||
return timeout
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue