zed-industries/zed · error
No `document` found on window
Error message
No `document` found on window
What it means
Guard in WebWindow::prepare_canvas: window.document() returned None, i.e. the JS global is not a fully initialized browsing context (e.g. worker scope, or DOM not ready). The canvas-preparation path requires a document node to create the drawing surface.
Source
Thrown at crates/gpui_web/src/window.rs:84
pub(crate) pressed_button: Cell<Option<MouseButton>>,
pub(crate) last_physical_size: Cell<(u32, u32)>,
pub(crate) notify_scale: Cell<bool>,
pub(crate) is_composing: Cell<bool>,
/// Set while `show_virtual_keyboard` blur/focus-cycles the hidden input.
/// The cycle is a keyboard-visibility hint, not a real activity change;
/// letting the focus/blur listeners report it would re-enter GPUI
/// synchronously from inside an input dispatch, and a `RefCell`
/// double-borrow panic on wasm never unwinds, wedging the app.
pub(crate) suppress_focus_status_events: Cell<bool>,
/// The visual viewport height when the current pointer gesture began.
/// A mid-gesture change means the software keyboard opened or closed and
/// reflowed the layout, so the release position no longer refers to what
/// the user aimed at.
pub(crate) gesture_start_visual_viewport_height: Cell<f64>,
/// A touch that may still resolve into a tap: its pointer id and starting
/// position, cleared once it travels beyond touch slop. Virtual keyboard
/// and IME focus may only change when a touch release completes a tap;
/// pans must leave them untouched, or scrolling over editable content
/// flickers the keyboard and drags the caret around.
pub(crate) touch_tap_candidate: Cell<Option<(i32, Point<Pixels>)>>,
mql_handle: RefCell<Option<MqlHandle>>,
pending_physical_size: Cell<Option<(u32, u32)>>,
raf_id: Cell<Option<i32>>,
raf_function: RefCell<Option<js_sys::Function>>,
}
pub struct WebWindow {
inner: Rc<WebWindowInner>,
display: Rc<dyn PlatformDisplay>,
lifecycle: Rc<Cell<WebWindowLifecycle>>,
active_window: Rc<RefCell<Option<AnyWindowHandle>>>,
_raf_closure: Closure<dyn FnMut()>,
_resize_observer: Option<web_sys::ResizeObserver>,
_resize_observer_closure: Closure<dyn FnMut(js_sys::Array)>,
_safe_area_observer: Option<web_sys::ResizeObserver>,
_safe_area_observer_closure: Closure<dyn FnMut(js_sys::Array)>,View on GitHub (pinned to 9d272b0363)
Solutions
- Ensure GPUI web code runs on the main thread with a DOM (not in a Worker)
- Defer initialization until DOMContentLoaded when the document may not exist yet
- Fail with this descriptive error before attempting any canvas/DOM operations
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/gpui_web/src/window.rs:82 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/0a47af7eb17061dd.
Report an issue: GitHub.