-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
What happened?
问题描述
在 Electron 应用中使用 @qwen-code/sdk@0.1.5-preview.1 时,CLI 进程启动后立即崩溃,报错:
Apply
PlainText
ERROR Cannot read properties of undefined (reading 'themeError')
这导致 SDK 的 ProcessTransport 报告:
Apply
PlainText
[ERROR] [ProcessTransport] CLI process exited with code 1
环境信息
SDK 版本: @qwen-code/sdk@0.1.5-preview.1
Node.js 版本: (请补充)
操作系统: macOS (Darwin)
使用场景: 在 Electron 应用中通过 SDK 编程方式调用
复现步骤
安装 @qwen-code/sdk@0.1.5-preview.1
使用 stream-json 格式运行 CLI:
Apply
bash
OPENAI_API_KEY="your-key"
OPENAI_BASE_URL="https://your-api-endpoint/v1"
node node_modules/@qwen-code/sdk/dist/cli/cli.js
--input-format stream-json
--output-format stream-json
--channel=SDK
--model "your-model"
期望行为
CLI 应该成功启动,并在 stream-json 模式下等待输入。
实际行为
CLI 立即崩溃,报错如下:
Apply
PlainText
ERROR Cannot read properties of undefined (reading 'themeError')
node_modules/.pnpm/@qwen-code+sdk@0.1.5-preview.1_.../dist/cli/cli.js:433485:26
433482 const [debugMessage, setDebugMessage] = (0, import_react133.useState)("");
433483 const [quittingMessages, setQuittingMessages] = (0, import_react133.useState)(null);
433484 const [themeError, setThemeError] = (0, import_react133.useState)(
433485 initializationResult.themeError
433486 );
错误堆栈
Apply
PlainText
-AppContainer (dist/cli/cli.js:433485:26)
-react-stack-bottom-frame (dist/cli/cli.js:276029:20)
-renderWithHooks (dist/cli/cli.js:266865:24)
-updateFunctionComponent (dist/cli/cli.js:269314:21)
-beginWork (dist/cli/cli.js:270299:20)
-runWithFiberInDEV (dist/cli/cli.js:265701:72)
-performUnitOfWork (dist/cli/cli.js:273786:82)
-workLoopSync (dist/cli/cli.js:273637:43)
-renderRootSync (dist/cli/cli.js:273619:13)
-performWorkOnRoot (dist/cli/cli.js:273251:46)
根因分析
CLI 中的 AppContainer React 组件尝试访问 initializationResult.themeError,但此时 initializationResult 为 undefined。这表明初始化逻辑可能存在以下问题之一:
组件渲染前初始化逻辑未被调用
初始化过程静默失败,未设置结果
初始化流程存在竞态条件
配置文件
我的 ~/.qwen/settings.json 配置:
Apply
JSON
{
"$version": 3,
"modelProviders": {
"openai": [
{
"id": "DeepSeek-V3.2",
"envKey": "OPENAI_API_KEY",
"baseUrl": "https://antchat.alipay.com/v1"
}
]
},
"mcpServers": {
// ... MCP 服务器配置
}
}
临时解决方案
目前没有已知的解决方案。降级到之前的稳定版本(如 0.1.4)可能有效,但尚未测试。
补充信息
使用 --help 参数时 CLI 可以正常工作
错误仅在使用 --input-format stream-json 模式时发生
此问题阻塞了 SDK 在 Electron 应用中的集成
What did you expect to happen?
和历史对话进行会话时不会崩溃
Client information
Client Information
Run qwen to enter the interactive CLI, then run the /about command.
$ qwen /about
# paste output hereLogin information
No response
Anything else we need to know?
No response