zed-industries/zed · error
Missing document
Error message
Missing document
What it means
A sentinel guard in WebViewport::update: window.document() returned None while recomputing canvas bounds and safe-area insets for the frame. Per web-sys this only happens for non-HTML or transitional documents, so during a normal session it indicates the window/document is being torn down or is in an invalid state mid-update. The update aborts and the old cached bounds are kept.
Source
Thrown at crates/gpui_web/src/viewport.rs:51
}
pub(crate) fn observe_safe_area(&self, observer: &web_sys::ResizeObserver) {
// Separate boxes detect redistribution between edges even when the
// total inset, and therefore a single combined probe's size, is unchanged.
for probe in &self.safe_area_probes {
observer.observe(probe);
}
}
pub(crate) fn update(
&mut self,
window: &web_sys::Window,
canvas: &web_sys::HtmlCanvasElement,
) -> anyhow::Result<bool> {
let canvas_bounds = canvas.get_bounding_client_rect();
let document = window
.document()
.ok_or_else(|| anyhow::anyhow!("Missing document"))?;
let root = document
.document_element()
.ok_or_else(|| anyhow::anyhow!("Missing root"))?;
let layout_width = root.client_width() as f64;
let layout_height = root.client_height() as f64;
let (left, top, width, height) = match window.visual_viewport() {
Some(viewport) => (
viewport.offset_left(),
viewport.offset_top(),
viewport.width(),
viewport.height(),
),
None => (0., 0., layout_width, layout_height),
};
// VisualViewport offsets and getBoundingClientRect share layout CSS
// coordinates. Multiplying by the pinch scale here would incorrectly
// expand the visible rectangle back to its unzoomed size.
let x = (left - canvas_bounds.left()).clamp(0., canvas_bounds.width());View on GitHub (pinned to 9d272b0363)
Solutions
- Treat as a transient teardown signal: skip this frame's viewport update and keep the previous bounds
- Ensure update() is not invoked after the window is closed or during document unload
- If persistent, inspect the hosting document type; webviews serving XHTML or non-HTML content can trigger this
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/gpui_web/src/viewport.rs:51 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-09-12).
Data as JSON: /api/errors/371c8db762975e48.
Report an issue: GitHub.