Skip to content

fix(tauri-plugin-mcp-bridge): don't log benign mid-handshake disconnects as errors - #30

Merged
yokuze merged 1 commit into
hypothesi:mainfrom
vdavid:fix/ws-handshake-incomplete-noise
Jun 28, 2026
Merged

fix(tauri-plugin-mcp-bridge): don't log benign mid-handshake disconnects as errors#30
yokuze merged 1 commit into
hypothesi:mainfrom
vdavid:fix/ws-handshake-incomplete-noise

Conversation

@vdavid

@vdavid vdavid commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

A small PR this time:

Context

The accept loop logs every handle_connection error at ERROR.

Problem

When a client opens the TCP connection but drops before finishing the WebSocket upgrade (port probes, health checks, browsers/agents reconnecting), accept_async returns a protocol error like "Handshake not finished", so the host app's output fills with:

[MCP][WS_SERVER][ERROR] WebSocket connection error: WebSocket protocol error: Handshake not finished

It's routine, non-actionable churn, but at ERROR it reads like something's broken. If everything goes fine, I like my terminal output nice and clean.

Solution in the PR

The change handles the accept_async failure at its call site and returns early for the benign "client went away mid-handshake" cases (HandshakeIncomplete, ConnectionClosed/AlreadyClosed, and Io with ConnectionReset/UnexpectedEof/BrokenPipe). Every other error keeps propagating to the existing connection-error log, so real failures stay visible.

Test plan

This is how I tested it:

  • cargo check, cargo clippy (no new warnings), cargo fmt --check, and cargo test all pass for tauri-plugin-mcp-bridge.
  • Behavior is by inspection: the benign branch returns Ok(()) before the log site. To reproduce live: open a raw TCP connection to the bridge's WS port and close it without the upgrade — the [MCP][WS_SERVER][ERROR] line no longer appears, while a normal connect/disconnect is unaffected.

…cts as errors

A client that opens the TCP connection but drops before completing the WebSocket upgrade (port probes, health checks, browsers/agents reconnecting) makes `accept_async` return a protocol error such as "Handshake not finished". The accept loop logged that at ERROR (`[MCP][WS_SERVER][ERROR] WebSocket connection error: ...`), so routine, non-actionable connection churn showed up as errors in the host app's output.

Handle the `accept_async` failure at its call site: silently return for the benign "client went away mid-handshake" cases (`HandshakeIncomplete`, `ConnectionClosed`/`AlreadyClosed`, and `Io` with `ConnectionReset`/`UnexpectedEof`/`BrokenPipe`) and let every other error keep propagating to the existing connection-error log.
@yokuze

yokuze commented Jun 28, 2026

Copy link
Copy Markdown
Member

Thank you!

@yokuze
yokuze merged commit c828f51 into hypothesi:main Jun 28, 2026
15 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.

2 participants