Skip to content

fix(extension): prevent silent 431 wedge from localhost cookie overflow (fixes #2278) - #2282

Open
kagura-agent wants to merge 1 commit into
jackwener:mainfrom
kagura-agent:fix/daemon-ping-431-cookie-overflow
Open

fix(extension): prevent silent 431 wedge from localhost cookie overflow (fixes #2278)#2282
kagura-agent wants to merge 1 commit into
jackwener:mainfrom
kagura-agent:fix/daemon-ping-431-cookie-overflow

Conversation

@kagura-agent

Copy link
Copy Markdown
Contributor

Problem

Fixes #2278 — the extension silently never connects when the daemon's /ping returns HTTP 431.

Root cause: the localhost cookie jar (17 KB) exceeds Node's default 16 KB HTTP header limit. When connectAttempt() pings the daemon, the browser attaches the full cookie jar (default same-origin credentials), the daemon answers 431 Request Header Fields Too Large, and the !res.ok branch silently scheduleReconnect()s — the WebSocket is never attempted, and nothing is logged, so the wedge is invisible.

Fix

  1. Client (extension/src/background.ts)connectAttempt() pings with credentials: 'omit' so the browser no longer attaches the cookie jar to the ping, and a non-OK status now logs [opencli] daemon ping failed: HTTP <status> instead of silently swallowing it.
  2. Daemon (src/browser/daemon-lifecycle.ts)resolveDaemonLaunchSpec() prefixes --max-http-header-size=131072 (128 KB) so the daemon tolerates large headers on all HTTP endpoints (including /status and the WebSocket upgrade, which can't omit cookies).

Tests

  • extension/src/background.test.ts — new test asserting the ping uses credentials: 'omit', logs a non-OK HTTP 431, and does not open a WebSocket after a failed ping.
  • src/browser/daemon-lifecycle.test.ts — new test asserting the header-size flag precedes the entrypoint.

npx vitest run extension/src/background.test.ts src/browser/daemon-lifecycle.test.ts → 73/73 pass.

…ow (fixes jackwener#2278)

The daemon /ping preflight silently swallows non-OK responses, so a large
localhost cookie jar (>16KB) pushes the request past Node's default header
limit, the daemon answers 431, and the extension never attempts the WebSocket
connection — with no diagnostic anywhere.

- omit credentials on the /ping fetch so the browser does not attach the
  localhost cookie jar in the first place
- log the HTTP status (and the error on failure) instead of dropping them
- raise the daemon's --max-http-header-size to 128KB so the daemon can still
  serve endpoints even when a large cookie jar is attached
@kagura-agent

Copy link
Copy Markdown
Contributor Author

Hi @jackwener 👋 — gentle ping. This fix for #2278 (silent 431 wedge from localhost cookie overflow) has been open for 3 days with all CI green. Would appreciate a review when you have a moment. Happy to adjust anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extension silently never connects when daemon /ping returns 431 (localhost cookie overflow); ping preflight swallows status

1 participant