Preface¶
When connecting local inference services like LM Studio in DSH, long-context prefill can take a long time silently computing. If a request fails after exactly five minutes, the client reports terminated, but the model-side log shows Client disconnected, making it easy to first suspect DSH or the provider’s streamIdleTimeoutMs. In reality, Node’s built-in fetch uses undici, which has a default connection-level bodyTimeout of 300,000ms, and this is an “idle timer”: during the prefill phase when no body bytes are being sent, the timer doesn’t reset, and after five minutes undici will directly destroy the socket. This article introduces the community plugin dsh-undici-timeout-fix (maintainer: lilinhua0413, category: model inference) and how it handles this layer of limitation without modifying DSH itself.
What is this¶
dsh-undici-timeout-fix is a DSH Cordis plugin (npm package name dsh-undici-timeout-fix, version 1.1.0 in current documentation, MIT license). It replaces undici’s global dispatcher, setting headersTimeout and bodyTimeout to 0 (meaning disable the timers, rather than setting them to a specific duration), thereby preventing long-duration local model prefill from being cut off by undici’s 300-second body timeout.
DSH calls the OpenAI-compatible SDK through @deepseek-ai/dsh-llm-pi-ai (pi-ai), which uses the global fetch (Shims.getDefaultFetch()). The plugin installs the dispatcher when loaded, thus covering model-related HTTP requests without needing to patch the DSH core.
The Problem vs streamIdleTimeoutMs¶
When local model prefill exceeds approximately five minutes, the typical symptom is that the request ends with terminated, and the server shows Client disconnected. The cause is not in any DSH “total timeout” switch, but in undici’s default bodyTimeout: 300_000ms.
streamIdleTimeoutMs configures DSH/pi-ai’s own stream idle watchdog, which is a separate timer. Without installing this plugin, it may also trigger at 300,000ms; merely increasing streamIdleTimeoutMs often just lets undici trigger first, changing the error from stream idle timeout after 300000ms to a simple terminated. This plugin targets the undici transport layer; after installing the plugin, it’s still recommended to configure a sufficiently large streamIdleTimeoutMs separately for local providers as a finite fallback (see below).
Core Features¶
- When the plugin loads, it executes
setGlobalDispatcher(new Agent({ headersTimeout: 0, bodyTimeout: 0 })), disabling undici’s connection-level header/body idle timeouts. - Registers the plugin id
undici-timeout-fixthrough Cordis patch, integrating with the DSH plugin system. - Depends on
undici(^8.10.2in package.json), requires Node>=22.19. - README states: no
peerDependenciesare declared, so it generally won’t be blocked by DSH plugin version compatibility checks.
Installation and Activation¶
Before installation, please review the GitHub repository source code and MIT license yourself. The plugin runs with DSH process permissions, and like any third-party plugin, installation means trusting its code behavior.
Install from Release package (no dependency on plugin registry)¶
Download dsh-undici-timeout-fix-1.1.0.tgz from the repository’s Releases, then execute:
dsh plugin --profile <your-profile> add /path/to/dsh-undici-timeout-fix-1.1.0.tgz
The undici dependency will still be resolved from your accessible npm registry (or internal mirror).
Install from npm¶
dsh plugin --profile <your-profile> add dsh-undici-timeout-fix
You can also add the package name dsh-undici-timeout-fix in the DSH plugin management interface and point the installation source to the registry that provides the package. If pnpm’s minimumReleaseAge (default 24 hours) causes installation of an older version, you can specify:
dsh plugin add dsh-undici-timeout-fix@1.1.0
Manually write the patch¶
Add to the profile’s cordis.patch.yml:
- insert:
- id: undici-timeout-fix
name: 'dsh-undici-timeout-fix'
Must fully restart DSH¶
The dispatcher is set when the plugin loads; a running process won’t hot-reload. Completely exit DSH before starting it again (macOS requires Cmd+Q; just closing the window is not enough). The README points out that forgetting to restart is the most common reason for “installed but still failing.”
Typical Configuration: streamIdleTimeoutMs for Local Providers¶
After this plugin removes the 300-second upper limit at the transport layer, if there’s no finite watchdog on the DSH side, truly stuck connections might hang indefinitely. Configure a sufficiently large but finite streamIdleTimeoutMs for every provider pointing to a local model; unconfigured providers will still fall back to the default 300,000ms.
Example (from README, adjust field names and structure according to your actual profile):
- id: llm-pi-ai
name: "@deepseek-ai/dsh-llm-pi-ai"
config:
providers:
lmstudio1:
displayName: lmstudio
apiKeyEnv: LMSTUDIO1_API_KEY
api: openai-completions
baseURL: http://127.0.0.1:1234/v1/
streamIdleTimeoutMs: 1800000 # 30 minutes
models:
- id: qwen3.5-122b-a10b
name: qwen3.5-122b-a10b
If you don’t want to completely disable undici timers, you can use finite values in custom or forked versions (README example uses 3,600,000ms); this plugin’s default strategy is 0 meaning disable.
Verification and Troubleshooting¶
- Send a request with prefill clearly exceeding five minutes; if it completes normally, the fix has taken effect.
- Distinguish the timing source based on error messages:
| Error | Meaning |
|---|---|
terminated |
undici transport layer—this plugin handles this |
pi-ai stream idle timeout after xxxms |
DSH watchdog—increase the corresponding provider’s streamIdleTimeoutMs |
Applicable Scenarios and Notes¶
Who it’s for: Developers using local large models (like LM Studio) through OpenAI-compatible interfaces in DSH, where prefill or long periods without body output exceed five minutes.
Proxy environment variables: Do not set HTTP_PROXY, HTTPS_PROXY, ALL_PROXY. dsh-http-proxy installs an Agent with its own five-minute limit during boot and overrides this plugin; DSH installs proxy first, then loads plugins, so this plugin only reliably works without a proxy.
Platform: README records macOS (Darwin 24, Node 24.21.0, built-in undici 7.29.1) as tested and working; Windows is not yet verified, the code has no platform-specific logic, feedback through issues is welcome.
Ecosystem note: DSH adopts the “everything is a plugin” Cordis extension approach; SkillHub directory page is community-collected, with no official affiliation with DeepSeek/High-Flyer.
Conclusion¶
dsh-undici-timeout-fix locates the problem in undici’s global fetch default body idle timeout, uses a minimally invasive approach to replace the global dispatcher, and reminds users to configure streamIdleTimeoutMs simultaneously and avoid proxy plugins overriding the dispatcher. If you’re investigating “local models always disconnect at five minutes,” first use the error table to distinguish between undici and pi-ai watchdogs, then install and fully restart DSH according to the README.
- Directory page: https://www.skillhub.cn/plugins/lilinhua0413/dsh-undici-timeout-fix
- GitHub: https://github.com/lilinhua0413/dsh-undici-timeout-fix