{"record":{"id":"7b7cc84d689eb931","repo":"zed-industries/zed","slug":"idle-sleep-prevention-request-was-abandoned","errorCode":null,"errorMessage":"Idle sleep prevention request was abandoned","messagePattern":"Idle sleep prevention request was abandoned","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_linux/src/linux/platform.rs","lineNumber":1369,"sourceCode":"                request\n                    .close()\n                    .await\n                    .context(\"Failed to release idle sleep prevention\")\n                    .log_err();\n            })\n            .detach();\n    })\n}\n\n#[cfg(any(feature = \"wayland\", feature = \"x11\"))]\nasync fn await_idle_sleep_prevention(\n    guard_rx: oneshot::Receiver<Result<ActivityGuard>>,\n    executor: &BackgroundExecutor,\n) -> Result<ActivityGuard> {\n    match futures::future::select(guard_rx, executor.timer(Duration::from_secs(10))).await {\n        futures::future::Either::Left((Ok(result), _)) => result,\n        futures::future::Either::Left((Err(_), _)) => {\n            Err(anyhow!(\"Idle sleep prevention request was abandoned\"))\n        }\n        futures::future::Either::Right(_) => Err(anyhow!(\n            \"Idle sleep prevention acquisition timed out after 10 seconds\"\n        )),\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n    use gpui::{Point, px};\n\n    #[cfg(any(feature = \"wayland\", feature = \"x11\"))]\n    #[test]\n    fn rejects_null_xkb_context() {\n        let context = unsafe {\n            // libxkbcommon permits unref on null, matching the value returned by Context::new on failure.\n            xkb::Context::from_raw_ptr(std::ptr::null_mut())","sourceCodeStart":1351,"sourceCodeEnd":1387,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_linux/src/linux/platform.rs#L1351-L1387","documentation":"When requesting an idle-sleep prevention guard on Linux, the platform sends the request to the display-server thread and waits on a oneshot channel. If the sender side is dropped before answering — the request was abandoned, e.g. the backend implementing the guard was torn down — the receiver gets a RecvError and this error is returned.","triggerScenarios":"prevent_idle_sleep's inner request future completes with the guard_rx oneshot channel closed without a value: the Wayland/X11 helper task or the object responsible for producing the ActivityGuard was dropped/cancelled before replying.","commonSituations":"Shutting down or closing a window while an idle-inhibition request is in flight; the display backend thread exiting (display server disconnect) mid-request; a race where the app quits between issuing the request and the reply.","solutions":["Retry the idle-sleep prevention request once the platform/connection is confirmed alive.","Ensure the platform instance (window/display connection) outlives the prevent_idle_sleep call.","Check logs for Wayland/X11 connection errors that would kill the backend task handling the request.","If triggered at app shutdown, guard the call site so idle prevention is not requested during teardown."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match platform.prevent_idle_sleep(reason).await {\n    Err(e) if e.to_string().contains(\"abandoned\") => {\n        log::warn!(\"idle-sleep request abandoned, retrying once\");\n        platform.prevent_idle_sleep(reason).await?;\n    }\n    other => other?,\n}","preventionTips":["Do not tear down windows or the platform while an idle-inhibition request is in flight.","Keep idle-prevention requests on a live platform/connection instance.","Watch for Wayland/X11 disconnects in logs; re-establish the session before requesting guards.","Avoid issuing new guard requests during app shutdown."],"tags":["linux","gpui","oneshot-channel","idle-sleep","async"],"backgroundTag":"invalid-state-transition","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"}