You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Desktop startup fails with "desktop welcome: Web authentication failed" — per-launch dsh-auth cookies accumulate until the 16KB request-header limit returns 431
#11293
The packaged desktop app eventually fails to start with Error: desktop welcome: Web authentication failed (phase: startup). The authentication flow itself is healthy — the cause is accumulation: every app launch mints a new 30-day dsh-auth-* cookie whose name embeds the Host's ephemeral port. Browsers scope cookies by domain but not by port, so the cookie store for 127.0.0.1 grows by one entry per launch. After a few dozen launches the Cookie header sent to the Host exceeds Node's default 16 KB request-header limit and the server answers 431 Request Header Fields Too Large. The welcome handshake treats any non-2xx as fatal, so startup fails.
Environment
@deepseek-ai/dsh-desktop 0.2.2-alpha.2, win-x64 unsigned build, Electron 44.7.0, Node 24.21.
The involved code paths (apps/desktop/src/welcome-backend.ts, apps/desktop/src/main.ts, packages/client/connection/src/browser-auth.ts) are unchanged across recent 0.2.x releases, so any long-installed copy is susceptible once its cookie jar fills. Onset is gradual: roughly tens of launches.
Reproduction
Launch and quit the packaged desktop app repeatedly — each launch binds a new ephemeral port and adds one cookie.
Once the accumulated 127.0.0.1 cookies push the Cookie request header over 16 KB, every launch fails at startup with desktop welcome: Web authentication failed, retried several times before the backend controller stops the Host.
Root cause
authorizeIndex in packages/client/connection/src/browser-auth.ts answers the authenticated launch URL (/?token=…) with 303 plus Set-Cookie: dsh-auth-<base64url(sha256(authority))>=…; Max-Age=2592000; Path=/; HttpOnly; SameSite=Strict, where authority is 127.0.0.1:<port> and the port is ephemeral per launch.
Browsers and Electron's Chromium cookie jar scope cookies by domain and path — not by port — so previous launches' cookies are never overwritten or expired: one new 30-day entry per launch accumulates under 127.0.0.1.
connectDesktopWelcome (apps/desktop/src/welcome-backend.ts) fetches the launch URL with net.fetch and credentials: 'include'; Chromium attaches all matching cookies — by then tens of KB.
The Host webserver is a Node http server with the default 16 KB max request-header size, so it responds 431, and the non-2xx becomes the fatal startup error.
Evidence
Net-log capture of a failing launch: request header Cookie: [16186 bytes were stripped], response HTTP/1.1 431 Request Header Fields Too Large.
The app's cookie store (userData/Network/Cookies) contained 142dsh-auth-* entries, one per past launch.
The flow itself is healthy end to end: against both a source checkout and the packaged runtime started standalone (resources/runtime/cli/bin/dsh.cmd web), token → 303 + Set-Cookie → follow with cookie → 200; a minimal Electron net.fetch repro also stores the cookie and follows the redirect correctly. The failure is purely accumulated header size.
Suggested fixes
Any of these would stop the accumulation:
Purge stale entries before the handshake: the desktop main process owns the Electron session; before connectDesktopWelcome, remove existing dsh-auth-* cookies for the Host origin (session.cookies.get + cookies.remove). Pruning inside authorizeIndex cannot name the old cookies — their names depend on past random ports.
Make the cookie name port-independent: derive the cookie name from the origin without the port, so each launch overwrites the previous entry; the signed payload's authority can keep binding the full audience if that guarantee matters.
Belt-and-braces: reduce the 30-day lifetime — today's cookies outlive their process by a month.
Workaround for affected users
Quit the app, delete the Chromium cookie store in the app's user-data directory — %APPDATA%\@deepseek-ai\dsh-desktop\Network\Cookies on Windows (same Network/Cookies under the equivalent user-data path on macOS/Linux) — and relaunch. These cookies only carry per-launch local authentication, so nothing of value is lost. The failure will recur after a similar number of launches until the accumulation itself is fixed.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Summary
The packaged desktop app eventually fails to start with
Error: desktop welcome: Web authentication failed(phase: startup). The authentication flow itself is healthy — the cause is accumulation: every app launch mints a new 30-daydsh-auth-*cookie whose name embeds the Host's ephemeral port. Browsers scope cookies by domain but not by port, so the cookie store for127.0.0.1grows by one entry per launch. After a few dozen launches theCookieheader sent to the Host exceeds Node's default 16 KB request-header limit and the server answers431 Request Header Fields Too Large. The welcome handshake treats any non-2xx as fatal, so startup fails.Environment
@deepseek-ai/dsh-desktop0.2.2-alpha.2, win-x64 unsigned build, Electron 44.7.0, Node 24.21.apps/desktop/src/welcome-backend.ts,apps/desktop/src/main.ts,packages/client/connection/src/browser-auth.ts) are unchanged across recent 0.2.x releases, so any long-installed copy is susceptible once its cookie jar fills. Onset is gradual: roughly tens of launches.Reproduction
127.0.0.1cookies push theCookierequest header over 16 KB, every launch fails at startup withdesktop welcome: Web authentication failed, retried several times before the backend controller stops the Host.Root cause
authorizeIndexinpackages/client/connection/src/browser-auth.tsanswers the authenticated launch URL (/?token=…) with303plusSet-Cookie: dsh-auth-<base64url(sha256(authority))>=…; Max-Age=2592000; Path=/; HttpOnly; SameSite=Strict, whereauthorityis127.0.0.1:<port>and the port is ephemeral per launch.127.0.0.1.connectDesktopWelcome(apps/desktop/src/welcome-backend.ts) fetches the launch URL withnet.fetchandcredentials: 'include'; Chromium attaches all matching cookies — by then tens of KB.httpserver with the default 16 KB max request-header size, so it responds431, and the non-2xx becomes the fatal startup error.Evidence
Cookie: [16186 bytes were stripped], responseHTTP/1.1 431 Request Header Fields Too Large.userData/Network/Cookies) contained 142dsh-auth-*entries, one per past launch.resources/runtime/cli/bin/dsh.cmd web),token → 303 + Set-Cookie → follow with cookie → 200; a minimal Electronnet.fetchrepro also stores the cookie and follows the redirect correctly. The failure is purely accumulated header size.Suggested fixes
Any of these would stop the accumulation:
connectDesktopWelcome, remove existingdsh-auth-*cookies for the Host origin (session.cookies.get+cookies.remove). Pruning insideauthorizeIndexcannot name the old cookies — their names depend on past random ports.authoritycan keep binding the full audience if that guarantee matters.Workaround for affected users
Quit the app, delete the Chromium cookie store in the app's user-data directory —
%APPDATA%\@deepseek-ai\dsh-desktop\Network\Cookieson Windows (sameNetwork/Cookiesunder the equivalent user-data path on macOS/Linux) — and relaunch. These cookies only carry per-launch local authentication, so nothing of value is lost. The failure will recur after a similar number of launches until the accumulation itself is fixed.All reactions