Commit b747d56
fix: apply apiRequestTimeout consistently across providers (#567)
* fix(api): apply apiRequestTimeout consistently across OpenAI/Anthropic SDK providers
Wire getApiRequestTimeout() into every provider that instantiates an OpenAI
or Anthropic SDK client so the user-configured apiRequestTimeout setting
applies uniformly. Previously only openai/lm-studio and providers extending
BaseOpenAiCompatibleProvider honored it.
OpenAI SDK: openai-native, openai-codex, openrouter, router-provider
(lite-llm, zoo-gateway, opencode-go, vercel-ai-gateway), requesty, unbound,
xai, qwen-code.
Anthropic SDK: anthropic, minimax, anthropic-vertex.
* docs(i18n): list providers where apiRequestTimeout has no effect
Append the list of unsupported providers (Amazon Bedrock, Google Gemini,
GCP Vertex AI, Mistral, Ollama, VS Code LM API, Poe) to the
apiRequestTimeout setting description across all package.nls locales so
users can see at a glance which providers ignore the value.
* test(api): align provider tests with apiRequestTimeout wiring
Assert SDK clients receive a timeout option in providers updated by
4c82de4 (anthropic-vertex, openrouter, requesty, vercel-ai-gateway,
zoo-gateway), and stub vscode.workspace.getConfiguration in tests that
mock vscode as an empty object so getApiRequestTimeout() can run during
provider construction.
* docs(i18n): drop provider examples from apiRequestTimeout recommendation
The previous description recommended raising the timeout for "local
providers like LM Studio and Ollama" while also listing Ollama among
the providers where the setting has no effect. Drop the provider
examples from the recommendation so the two parts no longer
contradict; the unsupported list still spells out where the setting
has no effect.
* chore: fix typo in Turkish apiRequestTimeout description
* fix(api): round timeout ms and restrict apiRequestTimeout to 1-3600s
- Math.round() prevents float ms from Anthropic SDK validatePositiveInteger throw
- minimum changed from 0 to 1; removed unreachable <= 0 branch in getApiRequestTimeout
- return type narrowed from number | undefined to number
* docs(i18n): remove '0 = no timeout', scope GCP Vertex AI, add Moonshot to unsupported list
- removed '0 = no timeout' from all locales; minimum is now 1
- scoped GCP Vertex AI to '(Gemini models)' since Claude models on Vertex are supported
- added Moonshot to unsupported providers (uses Vercel AI SDK, no client-level timeout)
* docs(i18n): tighten apiRequestTimeout description across all locales
Restructured into 3 concise sentences: timeout info, local provider
recommendation, and alphabetized unsupported providers list. Fixed
Korean phrasing and unified Japanese fullwidth punctuation.
* refactor(api): extract timeout constants and validate range bounds
Pull the timeout bounds (1-3600s) and default (600s) into named
constants and a small isValidTimeout type-guard, so out-of-range
values fall back to the default just like NaN/non-number inputs.
Tests updated to cover the new boundary and out-of-range fallback
cases.
* test(api): cover timeout passthrough for Vertex auth variants
Add cases verifying timeout is forwarded to AnthropicVertex when
constructing with vertexJsonCredentials or vertexKeyFile, and mock
GoogleAuth so the auth-bound paths are exercised.
* test(api): make GoogleAuth mock newable in Vertex tests
Arrow functions cannot be invoked with `new`, so the mock threw
TypeError when the handler did `new GoogleAuth(...)`. Switch to a
regular function expression to match the AnthropicVertex mock.
* Add changeset for API request timeout
* refactor: standardize API request timeout handling across providers
- Refactor timeout handling logic in multiple API providers
- Improve consistency in timeout configuration and error handling
- Reduce code duplication across provider implementations
* refactor: use class field initialization for timeoutMs in BaseProvider
- Replace constructor-based initialization with class field initialization
- Removes unnecessary constructor when only initializing properties
- Follows modern TypeScript/JavaScript conventions for cleaner code
* fix(tests): add getConfiguration mock to vscode provider tests
Add workspace.getConfiguration mock to vertex.spec.ts and vscode-lm.spec.ts to fix test failures
* chore(i18n): update apiRequestTimeout description for Google Gemini clarification
- Update translation files to clarify that Google Gemini is not supported
either directly or through the Vertex AI platform
* test: add timeout config mock to provider tests
- Mock timeout-config module in anthropic-vertex, openai, openrouter, requesty, and zoo-gateway tests
- Add MOCK_TIMEOUT_MS constant for consistent timeout assertions
- Replace expect.any(Number) with explicit MOCK_TIMEOUT_MS value in timeout assertions
---------
Co-authored-by: Oh Daewoong <dw.oh@samsung.com>
Co-authored-by: Naved Merchant <naved.merchant@gmail.com>1 parent 0306f2b commit b747d56
48 files changed
Lines changed: 252 additions & 66 deletions
File tree
- .changeset
- src
- api/providers
- __tests__
- utils
- __tests__
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
12 | 25 | | |
13 | 26 | | |
14 | 27 | | |
| |||
56 | 69 | | |
57 | 70 | | |
58 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
59 | 77 | | |
60 | 78 | | |
61 | 79 | | |
| |||
66 | 84 | | |
67 | 85 | | |
68 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
69 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
70 | 139 | | |
71 | 140 | | |
72 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
| |||
117 | 123 | | |
118 | 124 | | |
119 | 125 | | |
120 | | - | |
| 126 | + | |
121 | 127 | | |
122 | 128 | | |
123 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
5 | 11 | | |
6 | 12 | | |
7 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
4 | 16 | | |
5 | 17 | | |
6 | 18 | | |
| |||
108 | 120 | | |
109 | 121 | | |
110 | 122 | | |
| 123 | + | |
111 | 124 | | |
112 | 125 | | |
113 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
3 | 9 | | |
4 | 10 | | |
5 | 11 | | |
| |||
82 | 88 | | |
83 | 89 | | |
84 | 90 | | |
| 91 | + | |
85 | 92 | | |
86 | 93 | | |
87 | 94 | | |
| |||
97 | 104 | | |
98 | 105 | | |
99 | 106 | | |
| 107 | + | |
100 | 108 | | |
101 | 109 | | |
102 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
5 | 11 | | |
6 | 12 | | |
7 | 13 | | |
| |||
118 | 124 | | |
119 | 125 | | |
120 | 126 | | |
| 127 | + | |
121 | 128 | | |
122 | 129 | | |
123 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
6 | 12 | | |
7 | 13 | | |
8 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
5 | 11 | | |
6 | 12 | | |
7 | 13 | | |
| |||
0 commit comments