What happened?
qwen-code 0.15.11 fails with Connection error. (cause: fetch failed) on Node.js 26 unless
fetchOptions.dispatcher is removed
What did you expect to happen?
fix this error
Client information
╭────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Status │
│ │
│ Qwen Code 0.15.11 (782403d) │
│ Runtime Node.js v26.0.0 / npm 11.12.1 │
│ OS darwin arm64 (24.6.0) │
│ │
│ Auth Coding Plan │
│ Base URL https://coding.dashscope.aliyuncs.com/v1 │
│ Model qwen3.6-plus │
│ Fast Model qwen3.6-plus │
│ Session ID 04d519fb-f557-45ba-bf45-050a47069b78 │
│ Sandbox no sandbox │
│ Proxy no proxy │
│ Memory Usage 264.3 MB │
│
Login information
No response
Anything else we need to know?
Environment
- qwen-code:
0.15.11
- Install method: Homebrew
- OS: macOS / Darwin
24.6.0
- Node.js:
v26.0.0
- npm:
11.12.1
- Auth type:
openai
- Model:
qwen3.6-plus
- Base URL:
https://coding.dashscope.aliyuncs.com/v1
- Config style:
modelProviders.openai[] with envKey: BAILIAN_CODING_PLAN_API_KEY
Actual Behavior
Running a minimal prompt fails with a connection error:
qwen -d -p hi --output-format json
Output:
{
"type": "assistant",
"message": {
"content": [
{
"type": "text",
"text": "[API Error: Connection error. (cause: fetch failed)]"
}
]
}
}
Debug log includes:
[ERROR] [OPENAI_ERROR] OpenAI API Error: Connection error.
Error: Connection error.
at OpenAI.makeRequest (.../qwen-code/cli.js:157505:17)
at async ContentGenerationPipeline.executeWithErrorHandling (...)
## Expected Behavior
The command should successfully call the configured OpenAI-compatible DashScope endpoint and return
a response.
## What I Verified
The configured API key, endpoint, model, request body, and streaming response are valid.
A direct Node fetch() call to the same endpoint works:
fetch("https://coding.dashscope.aliyuncs.com/v1/chat/completions", {
method: "POST",
headers: {
"content-type": "application/json",
authorization: "Bearer <redacted>"
},
body: JSON.stringify({
model: "qwen3.6-plus",
messages: [{ role: "user", content: "hi" }],
max_tokens: 16,
stream: true
})
})
This returns HTTP 200 with text/event-stream.
I also enabled --openai-logging, captured the full request body generated by Qwen Code, and replayed
that exact request body manually with Node fetch(). That also returned HTTP 200 and streamed chunks
correctly.
So the issue does not appear to be caused by:
- invalid API key
- invalid model name
- invalid base URL
- invalid request body
- streaming/SSE support
- DashScope rejecting the request
## Suspected Root Cause
The failure appears related to Qwen Code's runtime fetch options on Node.js 26.
In the bundled code, runtimeFetchOptions.ts creates an Undici dispatcher and passes it to the OpenAI
SDK:
function buildFetchOptionsWithDispatcher(sdkType, proxyUrl) {
try {
const dispatcher = getOrCreateSharedDispatcher(proxyUrl);
return { fetchOptions: { dispatcher } };
} catch {
return sdkType === "openai" ? void 0 : {};
}
}
Where getOrCreateSharedDispatcher() creates either undici.Agent or undici.ProxyAgent.
When I run Qwen Code normally, it fails. When I monkey-patch fetch() to remove init.dispatcher, the
same command succeeds.
Temporary preload used for verification:
const originalFetch = globalThis.fetch;
globalThis.fetch = function qwenFetchWithoutDispatcher(input, init) {
if (init && typeof init === "object" && "dispatcher" in init) {
const nextInit = { ...init };
delete nextInit.dispatcher;
return originalFetch(input, nextInit);
}
return originalFetch(input, init);
};
Run command:
NODE_OPTIONS=--import=/tmp/qwen-strip-dispatcher.mjs qwen -d -p hi --output-format json
This succeeds and returns:
Hi! What can I help you with?
## Workaround
Remove the injected fetchOptions.dispatcher via preload, or run qwen-code with a Node.js version
where this dispatcher path is compatible.
## Request
Could you check whether qwen-code should avoid passing a bundled Undici dispatcher to the OpenAI SDK
under Node.js 26, or gate this behavior behind proxy configuration only?
What happened?
qwen-code 0.15.11fails withConnection error. (cause: fetch failed)on Node.js 26 unlessfetchOptions.dispatcheris removedWhat did you expect to happen?
fix this error
Client information
╭────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Status │
│ │
│ Qwen Code 0.15.11 (782403d) │
│ Runtime Node.js v26.0.0 / npm 11.12.1 │
│ OS darwin arm64 (24.6.0) │
│ │
│ Auth Coding Plan │
│ Base URL https://coding.dashscope.aliyuncs.com/v1 │
│ Model qwen3.6-plus │
│ Fast Model qwen3.6-plus │
│ Session ID 04d519fb-f557-45ba-bf45-050a47069b78 │
│ Sandbox no sandbox │
│ Proxy no proxy │
│ Memory Usage 264.3 MB │
│
Login information
No response
Anything else we need to know?
Environment
0.15.1124.6.0v26.0.011.12.1openaiqwen3.6-plushttps://coding.dashscope.aliyuncs.com/v1modelProviders.openai[]withenvKey: BAILIAN_CODING_PLAN_API_KEYActual Behavior
Running a minimal prompt fails with a connection error:
qwen -d -p hi --output-format json Output: { "type": "assistant", "message": { "content": [ { "type": "text", "text": "[API Error: Connection error. (cause: fetch failed)]" } ] } } Debug log includes: [ERROR] [OPENAI_ERROR] OpenAI API Error: Connection error. Error: Connection error. at OpenAI.makeRequest (.../qwen-code/cli.js:157505:17) at async ContentGenerationPipeline.executeWithErrorHandling (...) ## Expected Behavior The command should successfully call the configured OpenAI-compatible DashScope endpoint and return a response. ## What I Verified The configured API key, endpoint, model, request body, and streaming response are valid. A direct Node fetch() call to the same endpoint works: fetch("https://coding.dashscope.aliyuncs.com/v1/chat/completions", { method: "POST", headers: { "content-type": "application/json", authorization: "Bearer <redacted>" }, body: JSON.stringify({ model: "qwen3.6-plus", messages: [{ role: "user", content: "hi" }], max_tokens: 16, stream: true }) }) This returns HTTP 200 with text/event-stream. I also enabled --openai-logging, captured the full request body generated by Qwen Code, and replayed that exact request body manually with Node fetch(). That also returned HTTP 200 and streamed chunks correctly. So the issue does not appear to be caused by: - invalid API key - invalid model name - invalid base URL - invalid request body - streaming/SSE support - DashScope rejecting the request ## Suspected Root Cause The failure appears related to Qwen Code's runtime fetch options on Node.js 26. In the bundled code, runtimeFetchOptions.ts creates an Undici dispatcher and passes it to the OpenAI SDK: function buildFetchOptionsWithDispatcher(sdkType, proxyUrl) { try { const dispatcher = getOrCreateSharedDispatcher(proxyUrl); return { fetchOptions: { dispatcher } }; } catch { return sdkType === "openai" ? void 0 : {}; } } Where getOrCreateSharedDispatcher() creates either undici.Agent or undici.ProxyAgent. When I run Qwen Code normally, it fails. When I monkey-patch fetch() to remove init.dispatcher, the same command succeeds. Temporary preload used for verification: const originalFetch = globalThis.fetch; globalThis.fetch = function qwenFetchWithoutDispatcher(input, init) { if (init && typeof init === "object" && "dispatcher" in init) { const nextInit = { ...init }; delete nextInit.dispatcher; return originalFetch(input, nextInit); } return originalFetch(input, init); }; Run command: NODE_OPTIONS=--import=/tmp/qwen-strip-dispatcher.mjs qwen -d -p hi --output-format json This succeeds and returns: Hi! What can I help you with? ## Workaround Remove the injected fetchOptions.dispatcher via preload, or run qwen-code with a Node.js version where this dispatcher path is compatible. ## Request Could you check whether qwen-code should avoid passing a bundled Undici dispatcher to the OpenAI SDK under Node.js 26, or gate this behavior behind proxy configuration only?