{"record":{"id":"4b7f7776053bc774","repo":"zed-industries/zed","slug":"failed-to-initialize-event-loop-handling-of-sleep-wake","errorCode":null,"errorMessage":"Failed to initialize event loop handling of sleep/wake events: {err:?}","messagePattern":"Failed to initialize event loop handling of sleep/wake events: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_linux/src/linux/x11/client.rs","lineNumber":363,"sourceCode":"                    }\n                }\n            })\n            .map_err(|err| {\n                anyhow!(\"Failed to initialize event loop handling of foreground tasks: {err:?}\")\n            })?;\n\n        handle\n            .insert_source(power_receiver, |event, _, client: &mut X11Client| {\n                if let calloop::channel::Event::Msg(event) = event {\n                    client\n                        .0\n                        .borrow_mut()\n                        .common\n                        .handle_system_power_event(event);\n                }\n            })\n            .map_err(|err| {\n                anyhow!(\"Failed to initialize event loop handling of sleep/wake events: {err:?}\")\n            })?;\n\n        let (xcb_connection, x_root_index) = XCBConnection::connect(None)?;\n        xcb_connection.prefetch_extension_information(xkb::X11_EXTENSION_NAME)?;\n        xcb_connection.prefetch_extension_information(randr::X11_EXTENSION_NAME)?;\n        xcb_connection.prefetch_extension_information(render::X11_EXTENSION_NAME)?;\n        xcb_connection.prefetch_extension_information(xinput::X11_EXTENSION_NAME)?;\n\n        // Announce to X server that XInput up to 2.4 is supported.\n        // Version 2.4 is needed for gesture events (GesturePinchBegin/Update/End).\n        // The server responds with the highest version it supports; if < 2.4,\n        // we must not request gesture event masks in XISelectEvents.\n        let xinput_version = get_reply(\n            || \"XInput XiQueryVersion failed\",\n            xcb_connection.xinput_xi_query_version(2, 4),\n        )?;\n        assert!(\n            xinput_version.major_version >= 2,","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_linux/src/linux/x11/client.rs#L345-L381","documentation":"During X11Client::new, gpui spawns its event-loop machinery including a watcher that forwards system power (sleep/wake) events into the platform's common handler. If spawning/initializing that event-loop component fails, the whole client construction fails with this error wrapping the underlying error in Debug form.","triggerScenarios":"Creating an X11 gpui platform when the background task or event-loop setup for sleep/wake (power) event handling returns an error — e.g. failure to spawn the watcher task on the executor or an inner initialization error propagated via map_err.","commonSituations":"Resource exhaustion (thread/task spawn failure) on constrained systems; executor shutdown during platform initialization; environment-specific failures where the power-event watcher cannot be set up while starting the app under X11.","solutions":["Read the wrapped `{err:?}` detail to identify the underlying initialization failure.","Retry launching the app; transient spawn failures usually stem from temporary resource exhaustion.","Check system limits (ulimit on threads/processes) and free memory if task spawning failed.","Ensure you are running on a supported X11 session and that the display connection is healthy."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// The error Debug is embedded; surface the cause chain to the user\nif let Err(e) = init_x11_platform() {\n    if e.to_string().contains(\"sleep/wake events\") {\n        log::error!(\"X11 platform init failed at power-event setup: {e:#}\");\n        // inspect system limits / resources before retrying\n    }\n    return Err(e);\n}","preventionTips":["Run the app on a healthy, supported X11 session.","Check thread/process ulimits on constrained systems before launching.","Keep the executor alive until platform initialization completes.","Log the wrapped {err:?} cause to pinpoint the failing subsystem."],"tags":["x11","linux","gpui","event-loop","initialization"],"backgroundTag":"module-init-failed","analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-09-12T19:35:53.743Z","contentChangedAt":"2026-09-12T19:35:53.743Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}