Skip to content

fix: hold a WebSocket close behind delayed frames, batch reports, hide wrapper internals - #21

Merged
vannt-dev merged 1 commit into
developfrom
fix/websocket-minors
Oct 5, 2026
Merged

vannt-dev merged 1 commit into
developfrom
fix/websocket-minors

Conversation

@vannt-dev

Copy link
Copy Markdown
Owner

Three of the minor follow-ups listed in #20.

  • Close order. When a socket closed while received frames were still delayed, the page got close first and the frames were dropped. The close event is now held until those frames are delivered, then re-dispatched with the same code, reason and wasClean. Like the frames, the re-dispatched event has isTrusted === false, and readyState is already CLOSED while the last frames arrive. Frames waiting to be sent are still dropped: the socket is gone.
  • Reports. The wrapper sent one binding call per changed frame. It now counts and sends one report per 250 ms; the background adds the count, bounded to 1–1000 per report since the page can call the binding itself. A page that unloads within that window loses those counts (statistics only).
  • Page-visible internals. The per-socket queue and the "re-dispatched" mark were properties on the socket and the event; they are now a WeakMap/WeakSet. window.__networkOverridesWsWrapper stays (the background needs it to clear rules) but is no longer enumerable.

Not done, on purpose:

  • attaching waits while an alert() is open — Runtime.evaluate cannot run under a dialog; nothing short of dismissing the page's dialog fixes it;
  • rules for the old origin applying briefly after a cross-origin navigation, and the small modal leftovers — no concrete defect to fix yet.

Tests

npm test 186/186 (5 new), npm run lint clean, npm run smoke 16/16, node scripts/e2e-websocket.mjs OK on Chromium.

🤖 Generated with Claude Code

@vannt-dev vannt-dev changed the title fix: WebSocket rule follow-ups (close order, batched reports, hidden internals) fix: hold a WebSocket close behind delayed frames, batch reports, hide wrapper internals Oct 5, 2026
@vannt-dev
vannt-dev merged commit 00582fd into develop Oct 5, 2026
3 checks passed
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.

1 participant