mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-24 11:14:23 +01:00
fix: timeout option (#3229)
This commit is contained in:
@@ -413,8 +413,21 @@ export namespace Provider {
|
||||
const mod = await import(modPath)
|
||||
if (options["timeout"] !== undefined) {
|
||||
// Only override fetch if user explicitly sets timeout
|
||||
options["fetch"] = async (input: any, init?: any) => {
|
||||
return await fetch(input, { ...init, timeout: options["timeout"] })
|
||||
options["fetch"] = async (input: any, init?: BunFetchRequestInit) => {
|
||||
const { signal, ...rest } = init ?? {}
|
||||
|
||||
const signals: AbortSignal[] = []
|
||||
if (signal) signals.push(signal)
|
||||
signals.push(AbortSignal.timeout(options["timeout"]))
|
||||
|
||||
const combined = signals.length > 1 ? AbortSignal.any(signals) : signals[0]
|
||||
|
||||
return fetch(input, {
|
||||
...rest,
|
||||
signal: combined,
|
||||
// @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"))!]
|
||||
|
||||
Reference in New Issue
Block a user