Conversation
headerTimeout, chunkTimeout and timeout are enforced by the fetch wrapper resolveSDK installs on the provider SDK. The cloudflare-ai-gateway loader ignores that SDK and builds its own clients, and ai-gateway-provider's REST path calls the global fetch, so none of these options applied: a stalled gateway stream was never aborted and hung the session indefinitely. Extract the wrapper into timeoutFetch and use it in the gateway loader. Gateway requests go through ai-gateway-provider's binding hook, which sends the same POST (options as request-level cf-aig-* headers) the REST path does, and the REST catalog client receives it as its fetch.
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #51545
Type of change
What does this PR do?
headerTimeout,chunkTimeoutandtimeoutlive in the fetch wrapper thatresolveSDKadds, but thecloudflare-ai-gatewayloader ignores that SDK andai-gateway-providercalls the globalfetch. A stalled stream through AI Gateway therefore never aborts; we sawopencode github runhang until CI killed the job.The wrapper moves into a
timeoutFetch(options)helper, unchanged. The gateway loader uses it for both of its routes: throughcreateAiGateway'sbinding.runhook (it has nofetchoption), sending the same request as its REST path, and asfetchfor thecreateOpenAICompatiblecatalog route.Gateway models now get the default 300s header/chunk timeouts, where before they had none.
How did you verify your code works?
test/provider/header-timeout.test.ts(chunk stall on both routes, header stall). They fail without the change.bun test test/provider/ test/session/andbun typecheckinpackages/opencodepass.Screenshots / recordings
N/A
Checklist
🤖 Generated with Claude Code