fix(tauri-plugin-mcp-bridge): don't log benign mid-handshake disconnects as errors - #30
Merged
Conversation
…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.
Member
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A small PR this time:
Context
The accept loop logs every
handle_connectionerror 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_asyncreturns a protocol error like "Handshake not finished", so the host app's output fills with: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_asyncfailure at its call site and returns early for the benign "client went away mid-handshake" cases (HandshakeIncomplete,ConnectionClosed/AlreadyClosed, andIowithConnectionReset/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, andcargo testall pass fortauri-plugin-mcp-bridge.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.