{"record":{"id":"513eddfbba4ec2d9","repo":"leptos-rs/leptos","slug":"internal-error-entered-unreachable-code-513edd","errorCode":null,"errorMessage":"internal error: entered unreachable code","messagePattern":"internal error: entered unreachable code","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tachys/src/reactive_graph/inner_html.rs","lineNumber":65,"sourceCode":"            if let Some(mut state) = prev {\n                value.rebuild(&mut state);\n                state\n            } else {\n                value.build(&el)\n            }\n        })\n    }\n\n    fn rebuild(mut self, state: &mut Self::State) {\n        let prev_value = state.take_value();\n        *state = RenderEffect::new_with_value(\n            move |prev| {\n                let value = self.invoke();\n                if let Some(mut state) = prev {\n                    value.rebuild(&mut state);\n                    state\n                } else {\n                    unreachable!()\n                }\n            },\n            prev_value,\n        );\n    }\n\n    fn into_cloneable(self) -> Self::Cloneable {\n        self.into_shared()\n    }\n\n    fn into_cloneable_owned(self) -> Self::CloneableOwned {\n        self.into_shared()\n    }\n\n    fn dry_resolve(&mut self) {\n        self.invoke();\n    }\n","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/tachys/src/reactive_graph/inner_html.rs#L47-L83","documentation":"The `rebuild()` for a reactive `inner_html` binding creates/replaces a `RenderEffect` whose closure expects `Some(prev)` — the previous HTML string state used by `value.rebuild(&mut state)` to diff DOM inner HTML. `unreachable!()` means the effect ran with `prev == None`: the effect was seeded without a value (`prev_value` was `None`) or the value had been taken, so the diffing code had nothing to rebuild from.","triggerScenarios":"Updating a signal driving `inner_html={...}` when the binding's effect previous value is `None` — typically after the state was built via a non-seeding path (`RenderEffect::new` in hydration) or `rebuild` called before `build` committed `prev_value`.","commonSituations":"Hydrating SSR content where the reactive `inner_html` fires before the hydration path stores its initial value; custom view code calling `rebuild` on a state constructed manually; leptos version mismatches between the view macro and tachys runtime.","solutions":["Defer signal updates until after hydration/mount of the element completes.","Seed the effect with `RenderEffect::new_with_value(f, initial_html)` when constructing state manually.","Ensure `build`/`hydrate` runs before any `rebuild` on the same state.","Update leptos/tachys to the latest 0.7.x where async-effect seeding was corrected."],"exampleFix":"// before\nlet prev_value: Option<String> = None; // or taken\n*state = RenderEffect::new_with_value(move |prev| { /* expects Some */ }, prev_value);\n// after\nlet prev_value = Some(current_html);\n*state = RenderEffect::new_with_value(move |prev: Option<String>| { /* Some guaranteed */ }, prev_value);","handlingStrategy":"fallback","validationCode":"// Only bind reactive inner_html after the element state exists\nlet mounted = RwSignal::new(false);\nview! { <div inner_html={move || { if mounted.get() { html_signal.get() } else { String::new() } }} /> }\n// set mounted.set(true) after mount","typeGuard":"fn has_prev_html(prev: &Option<String>) -> bool { prev.is_some() }","tryCatchPattern":"// Panic; capture with hook\nstd::panic::set_hook(Box::new(|info| {\n    if info.to_string().contains(\"unreachable\") {\n        leptos::logging::error!(\"inner_html rebuild without prev state: {info}\");\n    }\n}));","preventionTips":["Avoid updating inner_html sources during hydration","Ensure build/hydrate runs before rebuild for the same state","Avoid sanitization-heavy dynamic HTML churn that triggers rebuilds pre-mount","Update leptos/tachys together, never independently"],"tags":["panic","reactivity","inner-html","leptos","tachys"],"backgroundTag":"unreachable-effect-previous-state-panicked","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}