Files
it-tools/src/tools/websocket-tester
SebastianandClaude Opus 5 903ffb8b90 refactor(websocket-tester): use the native WebSocket instead of w-websocket-client (#558)
* refactor(websocket-tester): use the native WebSocket instead of w-websocket-client

w-websocket-client ships a single 1465 byte UMD that wraps the platform
WebSocket: it builds `${url}/?token=${token}`, wires four handlers and returns
the socket. It nevertheless declares wsemi and lodash-es as runtime
dependencies, which its published build never imports, and wsemi alone pulls in
20 packages. Installing all of that to avoid writing twenty lines is a bad
trade, so the wrapper now lives here, behind tests.

Removes 14 packages from the lockfile (w-websocket-client, wsemi, diff2html,
tippy.js, @popperjs/core, seamless-scroll-polyfill, tree-kill, eventemitter3,
xxhash-wasm and their own transitives), and drops the Node-only `ws` from the
browser app's dependency graph; `ws` now only comes in through ethers.

Two follow-on effects:

- wsemi was the only subdependency wanting xlsx, which is why the xlsx CDN
  override forced pnpm's blockExoticSubdeps protection off repo-wide. Only this
  package depends on xlsx now, so the protection goes back to its default. A
  forced re-resolution of all 2484 packages passes with it enabled and leaves
  the lockfile byte identical.
- Connecting with an invalid url used to return { error } from the wrapper
  instead of a socket, so the next send() threw 'wsc.send is not a function'
  and nothing was ever logged. The failure is now reported in the log.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mf5V2jMpFFXxGVXZU5rHBq

* fix(websocket-tester): make connection errors readable and normalize the url

Both from review feedback on the pull request:

- The log showed 'Error: [object Event]' for a failed connection, because the
  native onerror handler receives a bare Event whose reason the websocket spec
  deliberately withholds. formatWebSocketError() turns it into 'connection
  failed', keeps the message of a real Error, and stringifies anything else.
  The old client had the same flaw, but this pr claims to report connection
  failures in the log, so it should actually report something.
- buildWebSocketUrl() now trims a trailing slash, so 'ws://host/' produces
  'ws://host/?token=...' rather than 'ws://host//?token=...'. This is a
  deliberate deviation from the previous client, which concatenated blindly.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mf5V2jMpFFXxGVXZU5rHBq

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-08-16 17:04:46 +02:00
..