diff options
| author | Aiden Cline <[email protected]> | 2025-10-16 17:47:41 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-10-16 17:47:41 -0500 |
| commit | b24f4e3d2c879ba1bfc6c0600c274f891f50055a (patch) | |
| tree | a6431a5e1c9e963651a3b1474ed3896428adcdee | |
| parent | 729ad1cb75bb4518ab83f6784d63f69b75626f58 (diff) | |
| download | opencode-b24f4e3d2c879ba1bfc6c0600c274f891f50055a.tar.gz opencode-b24f4e3d2c879ba1bfc6c0600c274f891f50055a.zip | |
fix: timeout option (#3229)
| -rw-r--r-- | packages/opencode/src/provider/provider.ts | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts index b4e87efc5..6e78ccbc0 100644 --- a/packages/opencode/src/provider/provider.ts +++ b/packages/opencode/src/provider/provider.ts @@ -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"))!] |
