Feature Request / PR: Add configurable Connection Timeout for LM Studio provider to prevent 5-minute disconnections #11068
linusky
started this conversation in
Feature Requests
Replies: 2 comments
-
|
Hello, Olivier |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I need this timeout setting as well |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
Currently, when using LM Studio as the API Provider for tasks that require long generation times, the connection gets silently dropped after exactly 5 minutes. LM Studio logs show
[LM STUDIO SERVER] Client disconnected. Stopping generation....This happens because VS Code's native global
fetchpatches the connection and enforces a strict 300-second timeout, ignoring custom dispatcher settings. To fix this, we need to bypass the global fetch by usingundicidirectly and expose a configurable timeout setting in the UI for LM Studio users.Proposed Solution & Implementation Details:
I have successfully implemented and tested this locally by making the following changes:
1. State Keys (
src/shared/storage/state-keys.ts):Added
lmStudioTimeoutMstoAPI_HANDLER_SETTINGS_FIELDS:2. LM Studio Provider (
src/core/api/providers/lmstudio.ts):Updated
LmStudioHandlerOptionsto includelmStudioTimeoutMs?: number.Modified the
createOpenAIClientcall to explicitly useundiciFetchwith a customAgentto ensure the timeout limits are respected:3. Settings UI (
webview-ui/src/components/settings/providers/LMStudioProvider.tsx):Added a new UI field for users to configure the timeout value in the LM Studio settings panel:
Why this is important:
Local LLM inference often requires much more time than cloud APIs, especially on older machines or with very large context windows. Giving users control over the
undicifetch timeout ensures they can use Cline with local LM Studio instances without arbitrary 5-minute cutoffs.Would love to see this integrated into the main branch!
Thank you
Beta Was this translation helpful? Give feedback.
All reactions