clockworklabs/SpacetimeDB · error
view `{}` for view id `{}` not found in current module
Error message
view `{}` for view id `{}` not found in current module What it means
The view-refresh path found the view's id in the st_views catalog, but the currently loaded module definition has no view with that catalogued name, so the definitions cannot be matched. On-disk schema state and the loaded module disagree — typically leftover catalog rows after a module update renamed or removed a view.
Source
Thrown at crates/core/src/host/module_host.rs:1182
/// its readset, `st_view`, and the [`ModuleDef`].
pub(crate) fn resolve_view_for_refresh<'a>(
tx: &MutTxId,
module_def: &'a ModuleDef,
view_call: &ViewCallInfo,
) -> anyhow::Result<ResolvedViewForRefresh<'a>> {
let st_view = tx
.lookup_st_view(view_call.view_id)
.with_context(|| format!("failed to look up view {}", view_call.view_id))?;
let view_id = st_view.view_id;
let table_id = st_view
.table_id
.ok_or_else(|| anyhow::anyhow!("view {:?} does not have a backing table", view_id))?;
let (global_fn_ptr, view_def, owning_def) = module_def
.view_by_name_with_global_fn_ptr(&st_view.view_name.clone().into())
.ok_or_else(|| {
anyhow::anyhow!(
"view `{}` for view id `{}` not found in current module",
st_view.view_name,
view_id
)
})?;
let is_anonymous = view_def.is_anonymous;
if st_view.is_anonymous != is_anonymous {
return Err(anyhow::anyhow!(
"found is_anonymous={} in st_view, but {} in module when updating view `{}`",
st_view.is_anonymous,
is_anonymous,
st_view.view_name,
));
}
Ok(ResolvedViewForRefresh {View on GitHub (pinned to 524b4487d9)
Solutions
- Re-publish the current module so catalog and module stay consistent.
- If the state is stale and data is disposable, delete and recreate the database.
- Avoid renaming or dropping views while subscriptions to them are live; make view renames two-step (add new, remove old) across publishes.
- Report with logs if it occurs without any schema changes on your side.
Defensive patterns
Strategy: try-catch
Try / catch
try {
await refreshViews(db);
} catch (e) {
if (String(e).includes('not found in current module')) {
await spacetimePublish(dbName, modulePath); // catalog/module drift: re-converge via publish
return refreshViews(db);
}
throw e;
} Prevention
- Publish schema changes while subscriptions to affected views are idle.
- Avoid renaming views in one step; add the new name first, migrate, then remove the old.
- Verify publishes complete successfully before rotating clients to the new module.
When it happens
Trigger: A module update drops or renames a view while a refresh for the old view id is still being processed; a publish interrupted between the catalog write and the module swap; replaying view refreshes against a module whose view set changed.
Common situations: Renaming or removing views between publishes; subscriptions/refreshes active during update; rolling back to an older module with different view names.
Related errors
- found is_anonymous={} in st_view, but {} in module when upda
- view {:?} does not have a backing table
- cannot serialize refs without a typespace
- cannot deserialize refs without a typespace
- could not serialize result: object had neither a `ok` nor an
AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16).
Data as JSON: /api/errors/80b4931d5a4894ed.
Report an issue: GitHub.