summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2025-11-19 16:20:10 -0600
committerAiden Cline <[email protected]>2025-11-19 16:20:29 -0600
commit51bba6e6343e5a120e501a77b8c4f6ba689c18c5 (patch)
treea8d1a297c3b9146fa73543487ccad59c88b2b561 /packages
parente1089bc5dec734a763842adbfa05707ae4611d81 (diff)
downloadopencode-51bba6e6343e5a120e501a77b8c4f6ba689c18c5.tar.gz
opencode-51bba6e6343e5a120e501a77b8c4f6ba689c18c5.zip
tweak: default to disabling fetch timeout in provider options
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/provider/provider.ts27
1 files changed, 15 insertions, 12 deletions
diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts
index 2ffe9357c..37e8e7663 100644
--- a/packages/opencode/src/provider/provider.ts
+++ b/packages/opencode/src/provider/provider.ts
@@ -516,26 +516,29 @@ export namespace Provider {
const modPath =
provider.id === "google-vertex-anthropic" ? `${installedPath}/dist/anthropic/index.mjs` : installedPath
const mod = await import(modPath)
- if (options["timeout"] !== undefined && options["timeout"] !== null) {
+
+ const customFetch = options["fetch"]
+
+ options["fetch"] = async (input: any, init?: BunFetchRequestInit) => {
// Preserve custom fetch if it exists, wrap it with timeout logic
- const customFetch = options["fetch"]
- options["fetch"] = async (input: any, init?: BunFetchRequestInit) => {
- const { signal, ...rest } = init ?? {}
+ const fetchFn = customFetch ?? fetch
+ const opts = init ?? {}
+ if (options["timeout"] !== undefined && options["timeout"] !== null) {
const signals: AbortSignal[] = []
- if (signal) signals.push(signal)
+ if (opts.signal) signals.push(opts.signal)
if (options["timeout"] !== false) signals.push(AbortSignal.timeout(options["timeout"]))
const combined = signals.length > 1 ? AbortSignal.any(signals) : signals[0]
- const fetchFn = customFetch ?? fetch
- return fetchFn(input, {
- ...rest,
- signal: combined,
- // @ts-ignore see here: https://github.com/oven-sh/bun/issues/16682
- timeout: false,
- })
+ opts.signal = combined
}
+
+ return fetchFn(input, {
+ ...opts,
+ // @ts-ignore see here: https://github.com/oven-sh/bun/issues/16682
+ timeout: false,
+ })
}
const fn = mod[Object.keys(mod).find((key) => key.startsWith("create"))!]
const loaded = fn({