Skip to content

fix(core): open Bun WebSockets without permessage-deflate - #623

Merged
klNuno merged 1 commit into
mainfrom
fix/ws-no-deflate
Oct 19, 2026
Merged

klNuno merged 1 commit into
mainfrom
fix/ws-no-deflate

Conversation

@klNuno

@klNuno klNuno commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Note

Clanker Claude Opus 5.5 is responding on behalf of meetsu

Cause

Bun's WebSocket client (1.4.2 and 1.4.3) offers permessage-deflate. Once Chrome's DevTools or the core's server accepts it, the client sometimes closes a sound stream with 1002: "control frame is fragmented", "unsupported control frame" or "unexpected opcode".

  • E2E coordination-bridge-live: 5 of the 6 failures in loop run 39173179305 (30 runs) are this close, with Chrome still running. That surfaces as "the browser is closed".
  • cli.test.ts "skipping async questions": run 39175454923 failed with the socket closed (1002: "Protocol error - unsupported control frame") against the core's server.

The bytes rule Chrome out. The #613 flake loop sends the devtools socket through a relay that checks every frame. On a local 1002, Chrome's stream was 516 well-formed deflated frames, and Bun closed 1 ms after the last one.

Fix

SOCKET_OPTIONS = { perMessageDeflate: false } (client.ts) goes to every Bun WebSocket client this repo opens:

  • the core client (CLI, agents, E2E);
  • the Windows DevTools socket;
  • the group relay's upstream;
  • the E2E and core test browsers.

Cost

Measured on the core-to-core hop, which is the only link here that leaves the machine:

  • boot: 3.9 KB before, 54 KB after (x14);
  • a thread of 40 messages: 24 KB before, 90 KB after (x3.7).

The phone and the browser UI keep compression, since their WebSocket is the browser's own and not Bun's. Loopback links (CLI, agents, DevTools) pay nothing that matters.

When compression comes back

Turn perMessageDeflate back on in SOCKET_OPTIONS once both hold:

Proof

  • socket-options.test.ts checks that the upgrade request carries no Sec-WebSocket-Extensions. It fails before the fix (3 offers) and passes after.
  • Affected core tests pass 120/120. Core and E2E typechecks pass.
  • Loop numbers, before and after, follow in a comment.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: beboite/boite/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4f0977f8-4c67-413b-b53f-6100e33820f8
📥 Commits

Reviewing files that changed from the base of the PR and between ab30db2 and 11ddf3a.

📒 Files selected for processing: 7
  • packages/core/src/browser/cdp.ts
  • packages/core/src/client.ts
  • packages/core/src/group/relay.ts
  • packages/core/test/browser/fixture.ts
  • packages/core/test/socket-options.test.ts
  • tests/e2e/group-devices.test.ts
  • tests/e2e/lib/cdp.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

klNuno added a commit that referenced this pull request Oct 19, 2026
@github-actions github-actions Bot added the core packages/core and packages/contracts label Oct 19, 2026
@klNuno
klNuno merged commit de93f43 into main Oct 19, 2026
48 of 51 checks passed
@klNuno
klNuno deleted the fix/ws-no-deflate branch October 19, 2026 03:26
klNuno added a commit that referenced this pull request Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core packages/core and packages/contracts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant