{"record":{"id":"940b482d7bc28eb8","repo":"bevyengine/bevy","slug":"this-scene-has-not-been-resolved-yet-and-cannot-be","errorCode":null,"errorMessage":"This scene has not been resolved yet and cannot be spawned. It is likely waiting for dependencies to load","messagePattern":"This scene has not been resolved yet and cannot be spawned\\. It is likely waiting for dependencies to load","errorType":"exception","errorClass":"SpawnSceneError","httpStatus":null,"severity":"error","filePath":"crates/bevy_scene/src/scene_patch.rs","lineNumber":104,"sourceCode":"        resolved\n            .apply(entity, &mut BundleScratch::default())\n            .map_err(SpawnSceneError::ApplySceneError)\n    }\n}\n\n/// An [`Error`] that occurs during scene spawning.\n#[derive(Error, Debug)]\npub enum SpawnSceneError {\n    /// Failed to apply a [`ResolvedScene`].\n    ///\n    /// [`ResolvedScene`]: crate::ResolvedScene\n    #[error(transparent)]\n    ApplySceneError(#[from] ApplySceneError),\n    #[error(transparent)]\n    /// Calling [`Scene::resolve`] failed.\n    ResolveSceneError(#[from] ResolveSceneError),\n    /// Attempted to spawn a scene that has not been resolved yet.\n    #[error(\"This scene has not been resolved yet and cannot be spawned. It is likely waiting for dependencies to load\")]\n    UnresolvedSceneError,\n}\n\n/// A component that, when added, will queue applying the given [`ScenePatch`] after the scene and its dependencies have been loaded and resolved.\n#[derive(Component, FromTemplate, Deref, DerefMut)]\npub struct ScenePatchInstance(pub Handle<ScenePatch>);\n\n/// An [`Asset`] that holds a [`SceneList`], tracks its dependencies, and holds a [`ResolvedSceneListRoot`] (after the [`SceneList`] has been loaded and resolved)\n#[derive(Asset, TypePath)]\npub struct SceneListPatch {\n    /// A [`SceneList`].\n    pub scene_list: Option<Box<dyn SceneList>>,\n\n    /// The dependencies of `scene_list` (populated using [`SceneList::register_dependencies`]). These are \"asset dependencies\" and will affect the load state.\n    #[dependency]\n    pub dependencies: Vec<UntypedHandle>,\n\n    /// The [`ResolvedSceneListRoot`], if exists. This is populated after the scene list and its dependencies have been loaded and resolved.","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_scene/src/scene_patch.rs#L86-L122","documentation":"Variant of SpawnSceneError returned by ScenePatch::spawn/apply (and the scene-list equivalents). The patch's `resolved` field is still None, meaning ScenePatch::resolve has not completed — typically because the scene or its dependencies are still loading. The scene cannot be spawned until resolution finishes.","triggerScenarios":"Calling patch.spawn(&mut world) or patch.apply(entity) in the same frame the ScenePatch was created/loaded, before dependencies finish loading and resolve runs; the .ok_or(UnresolvedSceneError) on the resolved Option triggers.","commonSituations":"Startup systems that spawn a scene immediately after requesting it; level streaming code that assumes loads are synchronous; tests that forget to pump the asset server.","solutions":["Use world.queue_spawn_scene / queue_spawn_scene_list which defer spawning until load + resolve complete","Gate spawning on the patch's resolved state: check patch.resolved.is_some() in your system","In tests, advance app.update()/asset server until recursively_dependencies_loaded is true before spawning"],"exampleFix":"// before\nlet patch = ScenePatch::load(&server, scene);\nlet entity = patch.spawn(&mut world)?; // UnresolvedSceneError\n\n// after\nlet handle = world.queue_spawn_scene(scene); // spawns automatically once resolved","handlingStrategy":"validation","validationCode":"if patch.resolved.is_some() {\n    let entity = patch.spawn(&mut world)?;\n} else {\n    // not resolved yet: wait, or use queue_spawn_scene\n}","typeGuard":null,"tryCatchPattern":"match patch.spawn(&mut world) {\n    Err(SpawnSceneError::UnresolvedSceneError) => { /* wait for load+resolve, retry */ }\n    r => r?,\n}","preventionTips":["Use queue_spawn_scene / ScenePatchInstance so spawning defers until resolution completes","In tests, pump app.update() until dependencies report loaded before spawning"],"tags":["bevy","scene","async","spawn","load-state"],"backgroundTag":"async-not-ready","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}