glzr-io/glazewm · error

WebSocket error

Error message

WebSocket error: {}

What it means

`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.

Solutions

  1. Check the wrapped inner error in the message for the exact cause
  2. Update/fix the IPC client to close the connection cleanly
  3. Reconnect the client; the server continues serving other connections
Defensive patterns

Strategy: try-catch

Try / catch

match server.handle_connection(stream) {
  Err(e) if e.to_string().starts_with("WebSocket error") => {
    tracing::warn!("client connection failed: {e}; continuing to serve others");
  }
  r => r?,
}

Prevention

When it happens

Trigger: A client abruptly disconnects (TCP reset), sends malformed frames, or hits a protocol violation detected by the underlying WebSocket (tungstenite) implementation.

Common situations: glazewm-cli or a custom IPC client crashing or being killed mid-message, network interruption, or a client using an incompatible WebSocket protocol version.

Related errors


AI-assisted analysis of glzr-io/glazewm@5709ad0a3c (2026-09-08). Data as JSON: /api/errors/32375f0294bb8e2e. Report an issue: GitHub.

Appendix: source

Thrown at packages/wm/src/ipc_server.rs:113

    let res = async {
      loop {
        tokio::select! {
          Some(response) = response_rx.recv() => {
            outgoing.send(response).await?;
          }
          message = incoming.next() => {
            match message {
              Some(Ok(message)) => {
                if message.is_text() || message.is_binary() {
                  message_tx.send((
                    message.to_text()?.to_string(),
                    response_tx.clone(),
                    disconnection_tx.clone(),
                  ))?;
                }
              }
              Some(Err(err)) => bail!("WebSocket error: {}", err),
              None => {
                // WebSocket connection closed.
                break Ok(());
              },
            }
          }
        }
      }
    }
    .await;

    info!("IPC disconnection from: {}.", addr);

    if let Err(err) = disconnection_tx.send(()) {
      warn!("Failed to broadcast disconnection: {}", err);
    }

    res

View on GitHub (pinned to 5709ad0a3c)