tauri-apps/tauri · error
state not managed for field
Error message
state not managed for field `{}` on command `{}`. You must call `.manage()` before using this command What it means
When an IPC command declares a `State<T>` parameter, Tauri extracts it from the managed state map. If `.manage(T)` was never called on the app builder for type T, from_command cannot find it and the invocation fails with this message naming the field and command.
Solutions
- Call `.manage(MyType::default())` (or your instance) on the tauri::Builder before `.run()`
- Ensure the managed type exactly matches the command's State<T> generic (including wrappers like Mutex<T>)
- If state must be created in setup, use `app.manage(...)` before the frontend can invoke commands
Example fix
// before tauri::Builder::default() .invoke_handler(tauri::generate_handler![read_config]) .run(tauri::generate_context!()) // after tauri::Builder::default() .manage(AppConfig::default()) .invoke_handler(tauri::generate_handler![read_config]) .run(tauri::generate_context!())
Defensive patterns
Strategy: try-catch
Validate before calling
// Rust: assert at startup that all state types are managed
fn assert_managed(app: &tauri::App) {
assert!(app.state::<AppConfig>().inner() is ok: use app.try_state::<AppConfig>().is_some(), "AppConfig not managed");
} Type guard
fn managed<T: Send + Sync + 'static, R: tauri::Runtime>(cmd: &tauri::CommandItem<'_, R>) -> Option<tauri::State<'_, T>> {
cmd.message.webview_ref().try_state::<T>()
} Try / catch
// Frontend
try {
await invoke('read_config');
} catch (e) {
if (String(e).includes('state not managed')) console.error('Call .manage(AppConfig::default()) in the builder');
} Prevention
- Call .manage() for every type used in State<T> command params, right on the Builder chain
- Keep managed types in one module and add a unit test invoking each command in setup_test
- Match wrapper types exactly: State<Mutex<Foo>> needs .manage(Mutex<Foo>)
When it happens
Trigger: Invoking a command from the frontend whose signature includes `State<'_, MyType>` while `tauri::Builder::manage(MyType...)` was never called (or was called with a different type), during command argument deserialization.
Common situations: Forgetting `.manage()` in setup, managing the wrong concrete type (e.g. Mutex<Foo> vs Foo), state registered inside setup() after commands already invoked, or refactoring a command's state type without updating manage().
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- missing command scope for key
- state() called before manage() for
- app version build number cannot be greater than 65535
- app version major number cannot be greater than 255
- app version minor number cannot be greater than 255
AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18).
Data as JSON: /api/errors/07e6af003ab96506.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tauri/src/state.rs:63
}
impl<T: PartialEq> PartialEq for State<'_, T> {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for State<'_, T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple("State").field(&self.0).finish()
}
}
impl<'r, 'de: 'r, T: Send + Sync + 'static, R: Runtime> CommandArg<'de, R> for State<'r, T> {
/// Grabs the [`State`] from the [`CommandItem`]. This will never fail.
fn from_command(command: CommandItem<'de, R>) -> Result<Self, InvokeError> {
command.message.webview_ref().try_state().ok_or_else(|| {
InvokeError::from_anyhow(anyhow::anyhow!(
"state not managed for field `{}` on command `{}`. You must call `.manage()` before using this command",
command.key, command.name
))
})
}
}
// Taken from: https://github.com/SergioBenitez/state/blob/556c1b94db8ce8427a0e72de7983ab5a9af4cc41/src/ident_hash.rs
// This is a _super_ stupid hash. It just uses its input as the hash value. This
// hash is meant to be used _only_ for "prehashed" values. In particular, we use
// this so that hashing a TypeId is essentially a noop. This is because TypeIds
// are already unique integers.
#[derive(Default)]
struct IdentHash(u64);
impl std::hash::Hasher for IdentHash {
fn finish(&self) -> u64 {
self.0View on GitHub (pinned to 460ec35447)