{"record":{"id":"f7bb306fbd395ebf","repo":"glzr-io/glazewm","slug":"failed-to-send-response","errorCode":null,"errorMessage":"Failed to send response: {}","messagePattern":"Failed to send response: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/wm/src/ipc_server.rs","lineNumber":163,"sourceCode":"\r\n    let response_data =\r\n      app_command\r\n        .map_err(anyhow::Error::msg)\r\n        .and_then(|app_command| {\r\n          self.handle_app_command(\r\n            app_command,\r\n            response_tx,\r\n            disconnection_tx,\r\n            wm,\r\n            config,\r\n          )\r\n        });\r\n\r\n    // Respond to the client with the result of the command.\r\n    response_tx\r\n      .send(Self::to_client_response_msg(message, response_data)?)\r\n      .map_err(|err| {\r\n        anyhow::anyhow!(\"Failed to send response: {}\", err)\r\n      })?;\r\n\r\n    Ok(())\r\n  }\r\n\r\n  #[allow(clippy::too_many_lines)]\r\n  fn handle_app_command(\r\n    &self,\r\n    app_command: AppCommand,\r\n    response_tx: &mpsc::UnboundedSender<Message>,\r\n    disconnection_tx: &broadcast::Sender<()>,\r\n    wm: &mut WindowManager,\r\n    config: &mut UserConfig,\r\n  ) -> anyhow::Result<ClientResponseData> {\r\n    let response_data = match app_command {\r\n      AppCommand::Query { command } => match command {\r\n        QueryCommand::Windows => {\r\n          ClientResponseData::Windows(WindowsData {\r","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/glzr-io/glazewm/blob/5709ad0a3c7c386bbc3e38166a865ffc12937515/packages/wm/src/ipc_server.rs#L145-L181","documentation":"`IpcServer::process_message` executes a client command and then pushes the result back through the per-client `response_tx` channel. If the receiving end is gone (client disconnected) or the channel is closed, `send` fails and the error is wrapped as \"Failed to send response\". It indicates the response could not be delivered, not that the command itself failed.","triggerScenarios":"A WebSocket client sends a command then disconnects before `process_message` finishes, so the response channel's receiver is dropped; or the server is shutting down and the response channel was closed.","commonSituations":"Short-lived CLI invocations where the client times out or exits early; network drops mid-request; automated scripts firing fire-and-forget commands and closing the connection immediately.","solutions":["Keep the client (or its receiver) connected until the response arrives; await the response message before closing the WebSocket.","In the client, handle disconnects gracefully and treat this server-side bail as a lost response, not a command failure.","Re-send the command if a response is required and the connection dropped.","If writing wm-ipc-client code, ensure the connection stays open for the request duration (don't drop/reconnect mid-request).","Check server logs for concurrent shutdown while requests are in flight; delay `stop()` until pending messages are processed."],"exampleFix":"// before (client)\nclient.send_command(msg);\nclient.disconnect();\n// after\nlet response = client.send_command(msg).await?;\nclient.disconnect();","handlingStrategy":"retry","validationCode":"fn connection_alive(client: &IpcClient) -> bool { client.is_connected() }","typeGuard":null,"tryCatchPattern":"match client.send_command(msg).await {\n  Ok(resp) => resp,\n  Err(e) if e.to_string().contains(\"Failed to send response\") => {\n    // reconnect and retry once\n    client.reconnect().await?;\n    client.send_command(msg).await?\n  }\n  Err(e) => return Err(e),\n}","preventionTips":["Keep the IPC connection open until the response arrives.","Don't fire-and-forget commands over the WebSocket if you need results.","Reconnect cleanly after network drops before re-sending."],"tags":["rust","ipc","websocket","channel"],"backgroundTag":"broken-pipe","analyzedSha":"5709ad0a3c7c386bbc3e38166a865ffc12937515","analyzedAt":"2026-09-08T03:26:40.288Z","contentChangedAt":"2026-09-08T03:26:40.288Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}