{"record":{"id":"adba92a3f9111710","repo":"zed-industries/zed","slug":"failed-to-append-canvas-to-body-error","errorCode":null,"errorMessage":"Failed to append canvas to body: {error:?}","messagePattern":"Failed to append canvas to body: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_web/src/window.rs","lineNumber":111,"sourceCode":"pub struct WebWindow {\n    inner: Rc<WebWindowInner>,\n    display: Rc<dyn PlatformDisplay>,\n    lifecycle: Rc<Cell<WebWindowLifecycle>>,\n    active_window: Rc<RefCell<Option<AnyWindowHandle>>>,\n    _raf_closure: Closure<dyn FnMut()>,\n    _resize_observer: Option<web_sys::ResizeObserver>,\n    _resize_observer_closure: Closure<dyn FnMut(js_sys::Array)>,\n    _safe_area_observer: Option<web_sys::ResizeObserver>,\n    _safe_area_observer_closure: Closure<dyn FnMut(js_sys::Array)>,\n    _event_listeners: WebEventListeners,\n}\n\nimpl WebWindow {\n    pub(crate) fn prepare_canvas(\n        browser_window: &web_sys::Window,\n    ) -> anyhow::Result<web_sys::HtmlCanvasElement> {\n        let document = browser_window\n            .document()\n            .ok_or_else(|| anyhow::anyhow!(\"No `document` found on window\"))?;\n        let canvas: web_sys::HtmlCanvasElement = document\n            .create_element(\"canvas\")\n            .map_err(|error| anyhow::anyhow!(\"Failed to create canvas element: {error:?}\"))?\n            .dyn_into()\n            .map_err(|error| anyhow::anyhow!(\"Created element is not a canvas: {error:?}\"))?;\n        canvas.set_tab_index(-1);\n\n        let style = canvas.style();\n        for (property, value) in [\n            (\"width\", \"100%\"),\n            (\"height\", \"100%\"),\n            (\"display\", \"block\"),\n            (\"outline\", \"none\"),\n            (\"touch-action\", \"none\"),\n            (\"-webkit-touch-callout\", \"none\"),\n            (\"user-select\", \"none\"),\n            (\"-webkit-user-select\", \"none\"),","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_web/src/window.rs#L93-L129","documentation":"Guard in WebWindow::prepare_canvas: body.appendChild(canvas) threw — {error:?} is the JS exception, typically a HierarchyRequestError (body is not attached, e.g. detached document) or a CSP violation blocking DOM insertion.","triggerScenarios":"Thrown at crates/gpui_web/src/window.rs:107 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the body is connected to the document before appending the canvas","Check page CSP for restrictions on DOM modification","Report the JS exception so the embedding-page issue is visible in diagnostics"],"exampleFix":null,"handlingStrategy":"try-catch","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"}