Skip to content

fix: suppress WebSocket handshakes from network list - #93

Merged
AmisKwok merged 5 commits into
mainfrom
perf/bump-1.7.2
Sep 2, 2026
Merged

AmisKwok merged 5 commits into
mainfrom
perf/bump-1.7.2

Conversation

@AmisKwok

@AmisKwok AmisKwok commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

Summary / 摘要

Stop WebSocket upgrade handshakes from appearing as fake HTTP GET entries in the network list, and ship related performance optimizations. / 阻止 WebSocket 握手以伪造的 HTTP GET 条目出现在网络列表中,并附带相关性能优化。

Changes / 变更

  • Suppress WebSocket upgrade handshakes from the network list via a runZoned flag so they no longer create bogus GET entries (e.g. https://echo.websocket.events:0#). / 通过 runZoned 标志抑制 WebSocket 握手进入网络列表,不再产生伪造的 GET 条目。
  • Correctly classify WebSocket handshakes and record them as WS entries with accumulated frames instead of GET requests. / 正确归类 WebSocket 握手,以 WS 条目(含累积帧)呈现,而非 GET 请求。
  • Optimize refresh throttling, viewers, body budget, and expand the public API. / 优化刷新节流、各查看器、body 预算,并扩展公开 API。
  • Scope CHANGELOG entries to lib/ changes and fix WS entry wording. / 将 CHANGELOG 范围限定为 lib/ 改动,并修正 WS 条目措辞。
  • Add a local WS echo server to the example so the WS capture demo works fully offline (no external echo service required). / 在示例中新增本地 WS 回显服务器,使 WS 抓取演示完全离线可用(无需外网 echo 服务)。

Context / 背景

WebSocket capture previously opened the underlying HttpClient upgrade as a normal GET request, polluting the network list with a malformed entry and an OS Error body. This change keeps the handshake out of the list while still recording the real WS session with its frames. / WebSocket 抓取此前会把底层 HttpClient 的 upgrade 当成普通 GET 请求,导致网络列表出现畸形条目与 OS Error body。本次改动让握手不再进入列表,同时仍以 WS 会话(含帧)记录真实连接。

Checklist / 检查项

  • Title follows Conventional Commits / 标题符合约定式提交
  • CI checks pass after merge / 合入后 CI 通过

Test plan

  • Open the inspector → Network tab, flip the WS switch ON, then open a WebSocket in the example; confirm a WS entry appears with frames and no bogus GET entry. / 打开检查器→Network,开启 WS 开关后发起 WebSocket,确认出现 WS 条目与帧,且无伪造 GET 条目。
  • Run flutter analyze and flutter test; all green. / 运行 flutter analyze 与 flutter test,全部通过。

🤖 Generated with Zero Buddy

…blic API

- coalesce notifyListeners via frame-aligned post-frame instead of per-change Timer
- MemoryViewer high-frequency cards now refresh via liveNotifier (no full rebuild)
- WebSocket detection uses Upgrade header, not just /ws path (avoids token leak)
- HttpOverrides now chains host overrides instead of replacing them
- memoize network/log filter results
- add global body memory budget (default 16MB) with accounting on eviction
- Dio concurrent same-URL responses match the longest-pending request
- mount only the active panel tab; warn on route-injection fallback
- export more public capabilities (memory/alert services, models, viewers)
- bump version 1.7.1 -> 1.7.2
…etwork list

- detect WS via URL scheme (ws/wss) at openUrl time; the Upgrade header is
  only set by WebSocket.connect AFTER openUrl resolves, so the old header
  check always returned false and handshakes like wss://echo.websocket.events
  were logged as normal GET requests, surfacing failed handshakes as
  'OS Error status -1' in the network list.
- add an FPS animation toggle to the example app to stress-test FPS
  (an idle app shows single-digit FPS because no frames are produced).
- document the dart format . step in the AGENTS.md local-verify checklist.
- add a changelog-scope rule to AGENTS.md: doc/example-only changes are not
  changelog-worthy; a pure version-bump commit is the allowed exception.
- correct the 1.7.2 WebSocket entry to describe URL-scheme-based detection.
… flag

- InspectorWebSocket.connect now wraps WebSocket.connect in a runZoned with
  wsHandshakeZoneKey; the HttpOverrides interceptor skips the raw handshake GET,
  so handshakes (including failed ones) no longer leak into the Network list as
  OS Error status -1 GETs. Captured frames still surface as WS entries when
  capture is enabled.
- update CHANGELOG 1.7.2 to reflect the runZoned-based mechanism.
The WS capture demo previously connected to the public wss://echo.websocket.events
endpoint, which is unreachable on many device networks, so the handshake failed
before any WS entry was created and the inspector showed nothing (or a socket
error). Bind a loopback echo server (127.0.0.1, random port) on startup and
have the demo connect to it, so WS capture is verifiable fully offline. Falls
back to the public echo service only if the local server fails to start.
@AmisKwok
AmisKwok merged commit ab833f8 into main Sep 2, 2026
10 checks passed
@AmisKwok
AmisKwok deleted the perf/bump-1.7.2 branch September 2, 2026 00:10
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