DioxusLabs/dioxus · error
Lazy value is not initialized. Make sure to call…
Error message
Lazy value is not initialized. Make sure to call `initialize` before dereferencing.
What it means
Lazy::get was called before the Lazy value was initialized and no constructor is available to initialize it on demand. The API contract requires calling `initialize` (or constructing with a constructor) before dereferencing.
Solutions
- Call `initialize` on the lazy value before dereferencing it, or use the accessor that initializes it on first use.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/fullstack/src/lazy.rs:98 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23).
Data as JSON: /api/errors/5f5fc57edc077b95.
Report an issue: GitHub.
Appendix: source
Thrown at packages/fullstack/src/lazy.rs:98
if self
.started_initialization
.swap(true, std::sync::atomic::Ordering::SeqCst)
{
self.value.wait();
return Ok(());
}
// Otherwise, we need to initialize the value
self.set(constructor().unwrap())?;
}
Ok(())
}
/// Get a reference to the value of the `Lazy` instance. This will block the current thread if the
/// value is not yet initialized.
pub fn get(&self) -> &T {
if self.constructor.is_none() {
return self.value.get().expect("Lazy value is not initialized. Make sure to call `initialize` before dereferencing.");
};
if self.value.get().is_none() {
self.initialize().expect("Failed to initialize lazy value");
}
self.value.get().unwrap()
}
}
impl<T: Send + Sync + 'static> Default for Lazy<T> {
fn default() -> Self {
Self::lazy()
}
}
impl<T: Send + Sync + 'static> std::ops::Deref for Lazy<T> {
type Target = T;View on GitHub (pinned to 24f6a829df)