fix(core): keep remote MCP requests open past Bun's fetch idle timeout (#58341)

This commit is contained in:
Luke Parker
2026-10-23 14:34:28 +10:00
committed by GitHub
Unverified
parent 8482dbf1e7
commit e49157b34c
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -19,6 +19,7 @@ import { OAuthMetadataSchema, OpenIdProviderDiscoveryMetadataSchema } from "@mod
import { Cause, Deferred, Effect } from "effect"
import type { ServerResponse } from "node:http"
import { ConfigMCP } from "@opencode/schema/config/mcp"
import { noTimeoutFetch } from "@opencode/util/no-timeout-fetch"
import { Credential } from "../credential.js"
import { OauthCallbackPage } from "../oauth/page.js"
import type { Integration } from "../integration.js"
@@ -36,8 +37,9 @@ const refreshKey = (url: string | URL, init: RequestInit | undefined) => {
}
// Bun's and Node's fetch types both apply here and the SDK's FetchLike wants Bun's Response, so the
// overload is picked by annotation and clone() is pinned to the type it was called on.
const base: FetchLike = fetch
// overload is picked by annotation and clone() is pinned to the type it was called on. A tool call
// can stay silent for minutes, so Bun's idle deadline is off; the MCP execution timeout still applies.
const base: FetchLike = noTimeoutFetch
const share = (pending: ReturnType<FetchLike>) => pending.then((response) => response.clone() as typeof response)
const send: FetchLike = (url, init) => {
+1 -1
View File
@@ -1,5 +1,5 @@
// Bun's fetch aborts requests after its default idle deadline (about five minutes). Clients that
// hold requests open for long-running work (session waits, event streams, plugin commands,
// shell calls) opt out while keeping every other init option, including `signal`.
export const noTimeoutFetch = ((request: RequestInfo | URL, init?: RequestInit) =>
export const noTimeoutFetch = ((request: Parameters<typeof fetch>[0], init?: RequestInit) =>
fetch(request, { ...init, timeout: false } as BunFetchRequestInit)) as typeof fetch