{"record":{"id":"5f64f9cb7cae8e01","repo":"leptos-rs/leptos","slug":"no-shared-context","errorCode":null,"errorMessage":"no shared context","messagePattern":"no shared context","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"leptos/src/suspense_component.rs","lineNumber":451,"sourceCode":"\n        let mut fut = Box::pin(ScopedFuture::new(ErrorHookFuture::new(\n            async move {\n                // race the local resource notifier against the set of tasks\n                //\n                // if there are local resources, we just return the fallback immediately\n                //\n                // otherwise, we want to wait for resources to load before trying to resolve the body\n                //\n                // this is *less efficient* than just resolving the body\n                // however, it means that you can use reactive accesses to resources/async derived\n                // inside component props, at any level, and have those picked up by Suspense, and\n                // that it will wait for those to resolve\n                select! {\n                    // if there are local resources, bail\n                    // this will only have fired by this point for local resources accessed\n                    // *synchronously*\n                    _ = local_rx => {\n                        let sc = Owner::current_shared_context().expect(\"no shared context\");\n                        sc.set_incomplete_chunk(self.id);\n                        if let Some(tx) =\n                            notify_error_boundary.write_value().take()\n                        {\n                            let _ = tx.send(());\n                        }\n                        None\n                    }\n                    _ = tasks_rx => {\n                        let children = {\n                            let mut children_lock = children.lock().or_poisoned();\n                            children_lock.take().expect(\"children should not be removed until we render here\")\n                        };\n\n                        // if we ran this earlier, reactive reads would always be registered as None\n                        // this is fine in the case where we want to use Suspend and .await on some future\n                        // but in situations like a <For each=|| some_resource.snapshot()/> we actually\n                        // want to be able to 1) synchronously read a resource's value, but still 2) wait","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/leptos/src/suspense_component.rs#L433-L469","documentation":"During SSR streaming of a Suspense component (to_html_async_with_buf), when a local resource resolves and the chunk must be marked incomplete, leptos fetches the global shared reactive context via Owner::current_shared_context().expect(...). The panic means serialization was invoked with no shared context installed — i.e. to_html/render-to-string was called without leptos' reactive runtime being set up.","triggerScenarios":"Calling to_html_async_with_buf (or a Suspense's HTML serializer) manually outside leptos' runtime setup; custom server integration that skips the owner/context initialization; using render helpers outside an act of set_global context.","commonSituations":"Custom axum/actix integrations not going through leptos' official server rendering entry points; tests that serialize Suspense views without creating a runtime; library code reusing the internal serializer in a fresh task.","solutions":["Use leptos' official server-rendering APIs (leptos_axum::render_route / render_to_string etc.) which install the shared context.","If serializing manually, create the runtime first (e.g. create_scope + Owner::with, or leptos' to_html entry points that set it up).","In tests, wrap serialization in run_scope/with the shared context created by leptos helpers.","Check you haven't spawned the serialization into a task that lost the owner; enter the owner inside the task."],"exampleFix":"// before\nlet html = suspense.to_html_async_with_buf(...); // no shared context\n// after\nlet html = leptos::ssr::render_to_string(|cx| view! { cx, <Suspense>...</Suspense> }).await;\n","handlingStrategy":"validation","validationCode":"// before custom SSR serialization, ensure the shared context exists\nassert!(leptos::Owner::current_shared_context().is_some(), \"run inside leptos SSR entry points\");\n","typeGuard":"fn shared_context_ready() -> bool {\n    leptos::Owner::current_shared_context().is_some()\n}\n","tryCatchPattern":null,"preventionTips":["Use leptos_axum / leptos_actix official render entry points","Never call internal to_html helpers from a bare task without an owner","In tests, serialize within run_scope"],"tags":["leptos","ssr","suspense","reactive-owner"],"backgroundTag":"missing-reactive-owner","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}