zed-industries/zed · error

Failed to create component preview

Error message

Failed to create component preview

What it means

Error in ComponentPreview::deserialize when reconstructing a serialized component preview workspace item: rebuilding the ComponentPreview entity inside the window failed (project, language registry, or user store unavailable, or the preview page could not be re-created), so the saved pane state cannot be restored.

Source

Thrown at crates/component_preview/src/component_preview.rs:840

        window.spawn(cx, async move |cx| {
            let user_store = user_store.clone();
            let language_registry = language_registry.clone();
            let weak_workspace = workspace.clone();
            let project = project.clone();
            cx.update(move |window, cx| {
                Ok(cx.new(|cx| {
                    ComponentPreview::new(
                        weak_workspace,
                        project,
                        language_registry,
                        user_store,
                        None,
                        preview_page,
                        window,
                        cx,
                    )
                    .expect("Failed to create component preview")
                }))
            })?
        })
    }

    fn cleanup(
        workspace_id: WorkspaceId,
        alive_items: Vec<ItemId>,
        _window: &mut Window,
        cx: &mut App,
    ) -> Task<anyhow::Result<()>> {
        delete_unloaded_items(
            alive_items,
            workspace_id,
            "component_previews",
            &ComponentPreviewDb::global(cx),
            cx,
        )

View on GitHub (pinned to f4178619ac)

Solutions

  1. Discard the stale serialized item state and open a fresh component preview
  2. Verify the project and language registry are initialized before deserialization
  3. Re-save workspace state after upgrading if the serialized format changed
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/component_preview/src/component_preview.rs:840 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/f7f465818e419409. Report an issue: GitHub.