Repository navigation
[Bug][Desktop 0.2.1-rc.3] 启动失败:累积的 dsh-auth-* cookie 撑爆 16 KiB #11332
moussetale
started this conversation in
General
Replies: 1 comment
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
桌面版 0.2.1-rc.3 在 Windows 上启动即失败,报 Error: desktop welcome: Web authentication failed。
定位为:每次启动都会新增一条与随机端口绑定的 dsh-auth-* cookie;Chromium 的 cookie 只按域名归档, 71 条全堆在 127.0.0.1 下;启动认证请求的 Cookie 头约 16.3 KB,超过 Node 默认 16 KiB maxHeaderSize,HTTP 层拒绝(431),上层报认证失败。重装无效。
Reproduction
正常使用桌面版(默认配置),每天启动十几次;
2–3 天后 %APPDATA%@deepseek-ai\dsh-desktop\Network\Cookies 中 dsh-auth-* 累积到约 66 条;
再启动一次 → 失败。
只读检测:
sql
SELECT count(*) FROM cookies WHERE name LIKE 'dsh-auth-%' AND host_key = '127.0.0.1';
Current behavior
host 日志:
代码块
time: 2026-10-28T10:12:55.349Z
source: host
phase: startup
--- error ---
Error: desktop welcome: Web authentication failed
at connectDesktopWelcome (file:///D:/dsh/resources/app.asar/lib/main.js:8886:31)
at async Object.start (.../main.js:12195:22)
renderer 无 error 级输出;重启、重装均无效;删除 Network\Cookies 可恢复(但丢本地状态)。
Expected behavior
无论历史 cookie 有多少,启动认证都不应失败;旧端口的 dsh-auth-* 应被回收,或不参与认证请求。
Environment
app: @deepseek-ai/dsh-desktop 0.2.1-rc.3
platform: win32 x64
Electron 44.7.0 / Node 24.21.0
根因与证据
(完整分析见附件 desktop-431-cookie-bug-report.md)
dsh-client-connection 的 browser-auth:cookie 名 = dsh-auth- + sha256(authority), 而 HTTP 下 authority 是 127.0.0.1:<随机端口> → 端口变,名字就变;
Chromium cookie 的 host_key 只到 127.0.0.1,端口不进域名 → 全部堆在一个桶, Max-Age 30 天(本机 expires_utc 实测);
lib/main.js:8884 认证请求用 fetch(authenticatedUrl, { credentials: "include" }),带全量 cookie;
实测:71 条 / 71 个不同端口(1209–11738)/ 48.9 小时内 / 约 24 次启动/天 / 71 × 约 230 B ≈ 16.3 KB > 16 KiB。
修复建议
desktop 侧:connectDesktopWelcome 不要用 credentials: "include",改为显式只带 Host 刚签发的 hostCookie(与 forwardWebRequest 一致)。这一处即可切断整类问题,无论 jar 里堆了多少。
cookie 名不绑端口(host-only),让每次启动覆盖同名 cookie。
Host 侧启动时清掉同域内旧 dsh-auth-*;或缩短 cookieMaxAgeDays。
兜底:Host 的 HTTP maxHeaderSize 调到 64 KiB,避免 431 直接变成启动失败。
DSH-431-提交包.zip
All reactions