{"record":{"id":"32375f0294bb8e2e","repo":"glzr-io/glazewm","slug":"websocket-error","errorCode":null,"errorMessage":"WebSocket error: {}","messagePattern":"WebSocket error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/wm/src/ipc_server.rs","lineNumber":113,"sourceCode":"\r\n    let res = async {\r\n      loop {\r\n        tokio::select! {\r\n          Some(response) = response_rx.recv() => {\r\n            outgoing.send(response).await?;\r\n          }\r\n          message = incoming.next() => {\r\n            match message {\r\n              Some(Ok(message)) => {\r\n                if message.is_text() || message.is_binary() {\r\n                  message_tx.send((\r\n                    message.to_text()?.to_string(),\r\n                    response_tx.clone(),\r\n                    disconnection_tx.clone(),\r\n                  ))?;\r\n                }\r\n              }\r\n              Some(Err(err)) => bail!(\"WebSocket error: {}\", err),\r\n              None => {\r\n                // WebSocket connection closed.\r\n                break Ok(());\r\n              },\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }\r\n    .await;\r\n\r\n    info!(\"IPC disconnection from: {}.\", addr);\r\n\r\n    if let Err(err) = disconnection_tx.send(()) {\r\n      warn!(\"Failed to broadcast disconnection: {}\", err);\r\n    }\r\n\r\n    res\r","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/glzr-io/glazewm/blob/5709ad0a3c7c386bbc3e38166a865ffc12937515/packages/wm/src/ipc_server.rs#L95-L131","documentation":"`handle_connection` reads messages from an accepted IPC WebSocket. When the stream yields `Err(err)`, the read failed mid-connection (not a clean close, which yields `None`), so it bails with the WebSocket error embedded.","triggerScenarios":"A client abruptly disconnects (TCP reset), sends malformed frames, or hits a protocol violation detected by the underlying WebSocket (tungstenite) implementation.","commonSituations":"glazewm-cli or a custom IPC client crashing or being killed mid-message, network interruption, or a client using an incompatible WebSocket protocol version.","solutions":["Check the wrapped inner error in the message for the exact cause","Update/fix the IPC client to close the connection cleanly","Reconnect the client; the server continues serving other connections"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match server.handle_connection(stream) {\n  Err(e) if e.to_string().starts_with(\"WebSocket error\") => {\n    tracing::warn!(\"client connection failed: {e}; continuing to serve others\");\n  }\n  r => r?,\n}","preventionTips":["Close IPC client connections cleanly before process exit","Keep WebSocket client libraries up to date for protocol compatibility","Log the inner tungstenite error for precise diagnosis"],"tags":["websocket","ipc","network"],"backgroundTag":"websocket-connection-error","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"}