zed-industries/zed · error
Failed to attach safe-area probe: {error:?}
Error message
Failed to attach safe-area probe: {error:?} What it means
The `?` on append_child for the safe-area probe divs failed: append_child returns a Result in web-sys, and this map_err wraps the JsValue error. The DOM refused to attach one of the probe elements (top/right/bottom/left) used to measure env(safe-area-inset-*). This is a generic DOM-mutation failure sentinel; the input at fault is the probe element/document pair being appended.
Source
Thrown at crates/gpui_web/src/viewport.rs:30
pub(crate) visible_bounds: Bounds<Pixels>,
pub(crate) insets: WindowInsets,
}
impl WebViewport {
pub(crate) fn new(document: &web_sys::Document) -> anyhow::Result<Self> {
let [top, right, bottom, left] =
["top", "right", "bottom", "left"].map(|edge| safe_area_probe(document, edge));
let viewport = Self {
safe_area_probes: [top?, right?, bottom?, left?],
visible_bounds: Bounds::default(),
insets: WindowInsets::default(),
};
let body = document
.body()
.ok_or_else(|| anyhow::anyhow!("Missing document body"))?;
for probe in &viewport.safe_area_probes {
body.append_child(probe)
.map_err(|error| anyhow::anyhow!("Failed to attach safe-area probe: {error:?}"))?;
}
Ok(viewport)
}
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();View on GitHub (pinned to 9d272b0363)
Solutions
- Retry initialization after the DOM is ready; appending before the document is fully parsed can transiently fail
- Check for DOM-mutation blockers (strict CSP, frameworks clearing body) that reject programmatic child insertion
- Log the {error:?} JsValue details to identify which edge probe failed and why
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at crates/gpui_web/src/viewport.rs:30 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/9518db245a7bfd11.
Report an issue: GitHub.