{"record":{"id":"cc36c94dca8a15a8","repo":"zed-industries/zed","slug":"missing-document-body","errorCode":null,"errorMessage":"Missing document body","messagePattern":"Missing document body","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_web/src/viewport.rs","lineNumber":27,"sourceCode":"\npub(crate) struct WebViewport {\n    safe_area_probes: [web_sys::HtmlElement; 4],\n    pub(crate) visible_bounds: Bounds<Pixels>,\n    pub(crate) insets: WindowInsets,\n}\n\nimpl WebViewport {\n    pub(crate) fn new(document: &web_sys::Document) -> anyhow::Result<Self> {\n        let [top, right, bottom, left] =\n            [\"top\", \"right\", \"bottom\", \"left\"].map(|edge| safe_area_probe(document, edge));\n        let viewport = Self {\n            safe_area_probes: [top?, right?, bottom?, left?],\n            visible_bounds: Bounds::default(),\n            insets: WindowInsets::default(),\n        };\n        let body = document\n            .body()\n            .ok_or_else(|| anyhow::anyhow!(\"Missing document body\"))?;\n        for probe in &viewport.safe_area_probes {\n            body.append_child(probe)\n                .map_err(|error| anyhow::anyhow!(\"Failed to attach safe-area probe: {error:?}\"))?;\n        }\n        Ok(viewport)\n    }\n\n    pub(crate) fn observe_safe_area(&self, observer: &web_sys::ResizeObserver) {\n        // Separate boxes detect redistribution between edges even when the\n        // total inset, and therefore a single combined probe's size, is unchanged.\n        for probe in &self.safe_area_probes {\n            observer.observe(probe);\n        }\n    }\n\n    pub(crate) fn update(\n        &mut self,\n        window: &web_sys::Window,","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_web/src/viewport.rs#L9-L45","documentation":"A sentinel error from the Option::ok_or_else guard when document.body() returned None while constructing the safe-area viewport. Browsers always expose a <body> for normal documents, so this fires only in unusual hosting scenarios (synthetic about:blank-like documents, initialization before the body is parsed, or non-HTML documents), and construction of the WebViewport aborts.","triggerScenarios":"Thrown at crates/gpui_web/src/viewport.rs:27 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the app initializes after DOMContentLoaded so document.body exists","If hosting in a synthetic or documentless context, provide or wait for a real HTML document before creating the viewport","Feature-detect document.body and defer viewport creation instead of failing hard"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}