{"record":{"id":"218894d1d0fe9901","repo":"Hmbown/CodeWhale","slug":"err-reconnect-failed-reconnect-err","errorCode":null,"errorMessage":"{err:#}; reconnect failed: {reconnect_err:#}","messagePattern":"(.+?); reconnect failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp.rs","lineNumber":4972,"sourceCode":"                                .config()\n                                .reviewed_plugin\n                                .as_ref()\n                                .map(|source| &source.authority)\n                                != route.plugin_authority.as_ref()\n                            || !conn.config().is_tool_enabled(&tool_name)\n                            || !conn.tools().iter().any(|tool| tool.name == tool_name)\n                        {\n                            Err(anyhow::anyhow!(\n                                \"MCP tool '{tool_name}' is disabled for server '{server_name}'\"\n                            ))\n                        } else {\n                            let timeout = conn.config().effective_execute_timeout(&global_timeouts);\n                            conn.call_tool(&tool_name, arguments, timeout).await\n                        }\n                    }\n                    // A reconnect that fails must not swallow the call error\n                    // that triggered it: report both, original first.\n                    Err(reconnect_err) => Err(anyhow::anyhow!(\n                        \"{err:#}; reconnect failed: {reconnect_err:#}\"\n                    )),\n                }\n            }\n            Err(err) => Err(err),\n        };\n        // A credential the server stopped accepting mid-session (revoked or\n        // rotated elsewhere, refresh rejected) is the same `◆ auth required`\n        // class as a failed connect: land it in the same typed state so the\n        // next catalog offers the login tool instead of a dead error.\n        result.map_err(|err| self.note_live_call_failure(&server_name, err))\n    }\n\n    /// Get list of configured server names (static + dynamic)\n    #[allow(dead_code)] // Public API for MCP consumers\n    pub fn server_names(&self) -> Vec<String> {\n        let mut names: Vec<String> = self\n            .config","sourceCodeStart":4954,"sourceCodeEnd":4990,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/mcp.rs#L4954-L4990","documentation":"When a tool call fails because the connection dropped, the pool attempts a reconnect; if that reconnect also fails, this error chains both — the original call error first, then the reconnect failure — so neither diagnosis is swallowed.","triggerScenarios":"conn.call_tool fails, the pool's reconnect path is entered, and the reconnect itself returns Err(reconnect_err); both messages are combined.","commonSituations":"MCP server process crashed mid-session and refuses to restart (bad command, port conflict, missing credentials); network drop with a broken config underneath.","solutions":["Read the original error (the first segment) — fix that root cause first, since reconnect only failed as a consequence","Verify the server can start at all (run its command manually, check auth/env)","Restart the session or remove/re-add the server config to force a clean reconnect"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify the server is reachable before heavy tool use\nif !conn.is_ready() { conn.reconnect().await?; }","typeGuard":null,"tryCatchPattern":"match call_tool(tool, args).await {\n    Err(call_err) => match reconnect().await {\n        Ok(fresh) => fresh.call_tool(tool, args).await,\n        Err(re) => Err(anyhow!(\"{call_err:#}; reconnect failed: {re:#}\")),\n    },\n    ok => ok,\n}","preventionTips":["Always preserve the original error when wrapping reconnect failures","Monitor server process health to catch crashes before tool calls fail","Test reconnect paths with servers that fail to start"],"tags":["mcp","reconnect","error-chaining","tool-call"],"backgroundTag":"connection-refused","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}