zed-industries/zed · error

Failed to initialize X11 event source: {err:?}

Error message

Failed to initialize X11 event source: {err:?}

What it means

Raised in X11Client::new: calloop could not insert the Generic fd source that polls the XCB connection fd for readable X11 events. {err:?} is calloop's InsertError; if this fails the loop never receives X11 protocol events.

Source

Thrown at crates/gpui_linux/src/linux/x11/client.rs:501

        // Safety: Safe if xcb::Connection always returns a valid fd
        let fd = unsafe { FdWrapper::new(Rc::clone(&xcb_connection)) };

        handle
            .insert_source(
                Generic::new_with_error::<EventHandlerError>(
                    fd,
                    calloop::Interest::READ,
                    calloop::Mode::Level,
                ),
                {
                    let xcb_connection = xcb_connection.clone();
                    move |_readiness, _, client| {
                        client.process_x11_events(&xcb_connection)?;
                        Ok(calloop::PostAction::Continue)
                    }
                },
            )
            .map_err(|err| anyhow!("Failed to initialize X11 event source: {err:?}"))?;

        handle
            .insert_source(XDPEventSource::new(&common.background_executor), {
                move |event, _, client| match event {
                    XDPEvent::WindowAppearance(appearance) => {
                        client.with_common(|common| common.appearance = appearance);
                        for window in client.0.borrow_mut().windows.values_mut() {
                            window.window.set_appearance(appearance);
                        }
                    }
                    XDPEvent::ButtonLayout(layout_str) => {
                        let layout = WindowButtonLayout::parse(&layout_str)
                            .log_err()
                            .unwrap_or_else(WindowButtonLayout::linux_default);
                        client.with_common(|common| common.button_layout = layout);
                        for window in client.0.borrow_mut().windows.values_mut() {
                            window.window.set_button_layout();
                        }

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Verify the xcb Connection's fd is valid and not already registered with the loop
  2. Check for calloop token/source limit exhaustion in long-running processes
  3. Abort startup with the propagated error rather than running a blind event loop
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/gpui_linux/src/linux/x11/client.rs:486 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20). Data as JSON: /api/errors/09760697ecf3f3e3. Report an issue: GitHub.