zed-industries/zed · error
Failed to append input to body: {e:?}
Error message
Failed to append input to body: {e:?} What it means
Fired in `Window::new` on the web backend when `input_element.append_child` (or equivalent DOM append of the hidden HTMLInputElement used for keyboard/text input capture) fails, e.g. because the canvas/document body is not attached or the element was already disposed. {e:?} carries the js_sys/DOMException.
Source
Thrown at crates/gpui_web/src/window.rs:161
#[allow(clippy::too_many_arguments)]
pub(crate) fn new(
_handle: AnyWindowHandle,
_params: WindowParams,
context: &WgpuContext,
canvas: web_sys::HtmlCanvasElement,
surface: wgpu::Surface<'static>,
browser_window: web_sys::Window,
lifecycle: Rc<Cell<WebWindowLifecycle>>,
active_window: Rc<RefCell<Option<AnyWindowHandle>>>,
) -> anyhow::Result<Self> {
let document = browser_window
.document()
.ok_or_else(|| anyhow::anyhow!("No `document` found on window"))?;
let body = document
.body()
.ok_or_else(|| anyhow::anyhow!("No `body` found on document"))?;
let dpr = browser_window.device_pixel_ratio() as f32;
let max_texture_dimension = context.device.limits().max_texture_dimension_2d;
let has_device_pixel_support = check_device_pixel_support();
let renderer_config = WgpuSurfaceConfig {
size: Size {
width: DevicePixels(0),
height: DevicePixels(0),
},
transparent: false,
preferred_present_mode: None,
};
let renderer = WgpuRenderer::new_from_surface(context, surface, renderer_config)?;
let touch_input = browser_window
.match_media("(pointer: coarse)")
.ok()
.flatten()
.is_some_and(|query| query.matches());
let ime_mirror = ImeMirror::new(&document, &body, touch_input)?;View on GitHub (pinned to 9d272b0363)
Solutions
- Verify the document body exists and is mounted before creating the window (window.document.body must be Some).
- Ensure the input element is created via the same document that hosts the canvas.
- Check browser console for the underlying DOMException (HierarchyRequestError, NotFoundError).
- Retry window creation after the DOM is fully loaded (wait for the `load`/DOMContentLoaded event).
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at crates/gpui_web/src/window.rs:154 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20).
Data as JSON: /api/errors/193d7f467322214f.
Report an issue: GitHub.