Repository navigation
[Bug] Windows 桌面版 Open In → VS Code 必然失败(dsh web 正常):ELECTRON_RUN_AS_NODE 泄漏到被启动的 launcher #10294
66JayLiang
started this conversation in
General
Replies: 1 comment
|
同一根因、同一处代码,已在 #10162 下给出可直接 cherry-pick 的分支(含两条回归测试):master...Yang-SVVG:fix/open-in-app-electron-run-as-node 你观察到的「 |
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.
Summary
桌面版(Electron)里,会话头部「Open In… → VS Code」必然失败,弹通用提示「打开失败,请重试」,且不会出现
Code.exe进程;同一台机器上的dsh web(3080)同一操作正常打开。根因不在路径解析,而在被启动进程的环境:桌面版进程带
ELECTRON_RUN_AS_NODE=1,scrubbedParentEnv()没有剥掉它,于是 spawn 出去的Code.exe <workspace 目录>以 node 模式运行,把目录当 JS 入口加载后以 1 退出,launchDetachedApp判为失败 →POST /open-in-app/open返回502 launch-failed→ 前端 toast。Reproduction
0.2.1.0/0.2.1-rc.2),打开任意 workspace 为真实目录的会话Code.exenpx @deepseek-ai/dsh web(本次为node ...\@deepseek-ai\dsh\lib\bin.js web,监听127.0.0.1:3080),同一会话、同一按钮 → 正常打开Current behavior
桌面版:launcher 以
exit 1结束,stderr 为路由返回
502 {"code":"launch-failed"}。网页版:
200,VS Code 打开该目录。资源管理器 / Git Bash:两边都正常。
Expected behavior
两种部署都应在 VS Code 中打开 workspace 目录。
Environment
10.0.26200build262000.2.1.0(file version0.2.1-rc.2),Electron@deepseek-ai/dsh0.2.1-rc.2@deepseek-ai/dsh-host-open-in-app0.2.1-rc.2@deepseek-ai/dsh-subprocess0.2.1-rc.21.142.0,%LOCALAPPDATA%\Programs\Microsoft VS Code\Code.exe,且在HKCU\...\App Paths\code.exe中注册C:\Program Files\Git\git-bash.exe根因(补充分析)
ELECTRON_RUN_AS_NODE=1。packages/subprocess/subprocess的scrubbedParentEnv()只过滤敏感变量和DSH_*:ELECTRON_RUN_AS_NODE因此原样传给子进程。packages/host/open-in-app的 vscode 条目以Code.exe+ 仅文件夹路径 启动:Code.exe(Electron 二进制)看到ELECTRON_RUN_AS_NODE=1就切到纯 node 模式,把目录当模块入口 → 报错、exit 1。launchDetachedApp只把exit 0当成功 → 判failed。dsh web由普通node.exe从终端启动,环境里没有该变量,所以同样的代码路径成功——这解释了为什么只有桌面版出问题。A/B 对照(同机)
Code.exe C:\Users\10983\Desktop\API3ELECTRON_RUN_AS_NODEELECTRON_RUN_AS_NODE=1Cannot find module …,exit 1使用与插件相同的 spawn 参数(
detached: true、stdio: "ignore")复现。受影响范围
Windows catalog 里所有 Electron 系条目:
vscode、vscodeinsiders、cursor、windsurf。原生/JVM 系(JetBrains、Sublime、Zed)不受影响。建议修复(二选一,前者足够)
ELECTRON_RUN_AS_NODE;更稳的是把整个ELECTRON_*家族从子进程环境里去掉,因为这些是宿主运行时开关,不该泄漏给被启动的应用。bin\code.cmd(内部是Code.exe "<install>\resources\app\out\cli.js" %*)。注意:Node 在 Windows 上不能直接 spawn.cmd(实测抛EINVAL),需要经cmd.exe /c,改动较大。附带建议:
launchDetachedApp失败时把「命令 + 退出码 + stderr」记进日志。目前失败只表现为通用 toast,排查成本很高。Workaround
需要「Open In → VS Code」时使用
dsh web;桌面版里用资源管理器 / Git Bash 两项;或命令行code <path>。All reactions