From e6f571c1db76966d9d7d896ab632b5d2dd40a9d7 Mon Sep 17 00:00:00 2001 From: kitt <11167504+kitt-cat@users.noreply.github.com> Date: Fri, 13 Mar 2026 08:46:56 -0700 Subject: [PATCH] gpui: Fix busyloop on X disconnect (#41986) When the connection to X is broken zed will go into an infinite loop and eat up 100% (of one core) of CPU; this change causes it to exit with an error instead. I encountered this behavior while running zed in [Xephyr](https://freedesktop.org/wiki/Software/Xephyr/) for testing, though I do sometimes terminate my X server as a way to log out or attempt to recover from a (very) broken state, and I appreciate a graceful exit in those situations! Exiting in case of X server disconnect is common practice in my observations, likely as the difficulty of recreating state stored server-side outweighs the potential utility in attempting to recover (if "reconnecting" to an X server is ever desired in regular usage, [Xpra](https://xpra.org/index.html) might be able to help!). Release Notes: - N/A --- crates/gpui_linux/src/linux/x11/client.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/gpui_linux/src/linux/x11/client.rs b/crates/gpui_linux/src/linux/x11/client.rs index 1f8db390029d67d8cdc17da7800a0f8e1d5e1af9..77f154201d3af6bb7504349e579a5be6b4edcbb5 100644 --- a/crates/gpui_linux/src/linux/x11/client.rs +++ b/crates/gpui_linux/src/linux/x11/client.rs @@ -602,6 +602,9 @@ impl X11Client { Ok(None) => { break; } + Err(err @ ConnectionError::IoError(..)) => { + return Err(EventHandlerError::from(err)); + } Err(err) => { let err = handle_connection_error(err); log::warn!("error while polling for X11 events: {err:?}");