{"record":{"id":"2e9f04c321218725","repo":"zed-industries/zed","slug":"attempted-to-read-a-window-that-is-already-on-the","errorCode":null,"errorMessage":"attempted to read a window that is already on the stack","messagePattern":"attempted to read a window that is already on the stack","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui/src/app.rs","lineNumber":2885,"sourceCode":"    where\n        T: 'static,\n    {\n        GpuiBorrow::new(handle.clone(), self)\n    }\n\n    fn read_entity<T, R>(&self, handle: &Entity<T>, read: impl FnOnce(&T, &App) -> R) -> R\n    where\n        T: 'static,\n    {\n        let entity = self.entities.read(handle);\n        read(entity, self)\n    }\n\n    fn update_window<T, F>(&mut self, handle: AnyWindowHandle, update: F) -> Result<T>\n    where\n        F: FnOnce(AnyView, &mut Window, &mut App) -> T,\n    {\n        self.update_window_id(handle.id, update)\n    }\n\n    fn with_window<R>(\n        &mut self,\n        entity_id: EntityId,\n        f: impl FnOnce(&mut Window, &mut App) -> R,\n    ) -> Option<R> {\n        App::with_window(self, entity_id, f)\n    }\n\n    fn read_window<T, R>(\n        &self,\n        window: &WindowHandle<T>,\n        read: impl FnOnce(Entity<T>, &App) -> R,\n    ) -> Result<R>\n    where\n        T: 'static,\n    {","sourceCodeStart":2867,"sourceCodeEnd":2903,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui/src/app.rs#L2867-L2903","documentation":"A reentrancy guard in App::read_window: window access uses a stack to detect recursive access, and reading a window whose handle is already on the stack panics with 'attempted to read a window that is already on the stack'. It fires when code running inside a window's context (layout, paint, or an update) synchronously re-enters the same window via read_window — reentrant access that GPUI forbids because it would alias mutable window state.","triggerScenarios":"Thrown at crates/gpui/src/app.rs:2850 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check whether the window is already on the stack (or pass the live &mut Window down) instead of re-entering via the handle","Defer the read with cx.defer/spawn so it runs after the current window access completes","Restructure callers to take Window as a parameter through the call chain rather than re-fetching it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}