{"record":{"id":"d21f2da97d7c4e4f","repo":"glzr-io/glazewm","slug":"ipc-connection-closed-unexpectedly","errorCode":null,"errorMessage":"IPC connection closed unexpectedly.","messagePattern":"IPC connection closed unexpectedly\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/wm-watcher/src/main.rs","lineNumber":136,"sourceCode":"    match event_data {\r\n      Some(WmEvent::WindowManaged { managed_window }) => {\r\n        if let ContainerDto::Window(window) = managed_window {\r\n          tracing::info!(\"Watcher added handle: {}.\", window.handle);\r\n          handles.push(window.handle);\r\n        }\r\n      }\r\n      Some(WmEvent::WindowUnmanaged {\r\n        unmanaged_handle, ..\r\n      }) => {\r\n        tracing::info!(\"Watcher removed handle: {}.\", unmanaged_handle);\r\n        handles.retain(|&handle| handle != unmanaged_handle);\r\n      }\r\n      Some(WmEvent::ApplicationExiting) => {\r\n        return Ok(());\r\n      }\r\n      Some(_) => unreachable!(),\r\n      None => {\r\n        anyhow::bail!(\"IPC connection closed unexpectedly.\")\r\n      }\r\n    }\r\n  }\r\n}\r\n","sourceCodeStart":118,"sourceCodeEnd":141,"githubUrl":"https://github.com/glzr-io/glazewm/blob/5709ad0a3c7c386bbc3e38166a865ffc12937515/packages/wm-watcher/src/main.rs#L118-L141","documentation":"The watcher process keeps an open IPC connection to the main WM while it watches managed window handles. If the event stream returns `None` — the WebSocket closed without the WM first sending `WmEvent::ApplicationExiting` — the watcher treats this as an abnormal shutdown and bails.","triggerScenarios":"The main glazewm.exe process is killed/crashes, the IPC socket drops mid-session, or the watcher loses the connection before receiving the graceful `ApplicationExiting` event.","commonSituations":"Force-killing the WM from Task Manager, WM crash, system shutdown forcibly terminating the parent, or an IPC server bug closing the socket.","solutions":["Restart the watcher/main WM processes so a fresh IPC connection is established","Check the main WM logs for a crash explaining the abrupt disconnect","If intentional cleanup is needed, have the WM emit `WmEvent::ApplicationExiting` before closing the IPC connection"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match watcher::watch_managed_handles() {\n  Ok(()) => {}\n  Err(e) if e.to_string().contains(\"IPC connection closed unexpectedly\") => {\n    tracing::warn!(\"WM exited without ApplicationExiting event; cleaning up\");\n  }\n  Err(e) => return Err(e),\n}","preventionTips":["Ensure the WM emits WmEvent::ApplicationExiting before shutting down","Monitor the WM process health from the watcher","Implement reconnect/backoff if the connection should be transient"],"tags":["ipc","websocket","process"],"backgroundTag":"connection-refused","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"}