Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/opencode/src/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ import { ModelStatus } from "./model-status"
import { RuntimeFlags } from "@/effect/runtime-flags"
import { ProviderError } from "./error"

const OPENAI_HEADER_TIMEOUT_DEFAULT = 300_000
// A connection that is established but silently blackholed (e.g. a broken IPv6
// path, see #36029/#39859) would otherwise wait for response headers forever.
const HEADER_TIMEOUT_DEFAULT = 300_000

function wrapSSE(res: Response, ms: number, ctl: AbortController) {
if (typeof ms !== "number" || ms <= 0) return res
Expand Down Expand Up @@ -205,7 +207,7 @@ function custom(dep: CustomDep): Record<string, CustomLoader> {
async getModel(sdk: any, modelID: string, _options?: Record<string, any>) {
return sdk.responses(modelID)
},
options: { headerTimeout: OPENAI_HEADER_TIMEOUT_DEFAULT },
options: { headerTimeout: HEADER_TIMEOUT_DEFAULT },
}),
meta: () =>
Effect.succeed({
Expand Down Expand Up @@ -1736,7 +1738,7 @@ const layer = Layer.effect(

const customFetch = options["fetch"]
const chunkTimeout = options["chunkTimeout"]
const headerTimeout = options["headerTimeout"]
const headerTimeout = options["headerTimeout"] ?? HEADER_TIMEOUT_DEFAULT
delete options["chunkTimeout"]
delete options["headerTimeout"]

Expand Down
2 changes: 1 addition & 1 deletion packages/opencode/test/provider/header-timeout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ it.live("headerTimeout aborts when response headers do not arrive", () =>
}),
)

it.live("headerTimeout is opt-in for non-OpenAI providers", () =>
it.live("default headerTimeout does not abort briefly delayed headers", () =>
Effect.gen(function* () {
const server = yield* Effect.acquireRelease(
Effect.promise(() => delayedHeaderServer(100)),
Expand Down
Loading