clockworklabs/SpacetimeDB · error · anyhow::Error
failed to look up materialized view args for view
Error message
failed to look up materialized view args for view {} What it means
While refreshing views during a procedure commit, the transaction's views_for_refresh queue lists a view instance, but tx.view_instance_args returns None - the st_view-instance row storing the materialized view's arguments (the sender identity) is missing. The refresh loop cannot reconstruct the view call, so the whole procedure transaction is rolled back.
Solutions
- Retry the mutating call once - transient races resolve after subscription state settles
- If persistent, let subscriptions quiesce (clients finish unsubscribing) before running reducers that touch the affected views
- Republish the module to rebuild view instance metadata and report the race with logs
Defensive patterns
Strategy: retry
Try / catch
match commit_result {
Err(e) if e.to_string().contains("failed to look up materialized view args") => {
// Subscription state changed mid-commit; retry the mutation after a short delay
}
other => other,
} Prevention
- Complete subscribe/unsubscribe operations before running reducers that touch the same views
- Keep reducers idempotent to make retries safe
- Report persistent occurrences - the args row should exist for every queued refresh
When it happens
Trigger: A materialized-view subscription being deleted (unsubscribe or client-disconnect cleanup) concurrently with a reducer commit that queued the same view for refresh; or missing/corrupted view instance metadata.
Common situations: Clients unsubscribing or disconnecting while reducers write to subscribed tables; partial metadata left by interrupted publishes.
Related errors
- export is a function with incorrect type
- Client not found
- `close` was called on this `NoDurability` instance
- Error resolving row type for view
- Error resolving row type for view
AI-assisted analysis of clockworklabs/SpacetimeDB@eddf9f5014 (2026-08-20).
Data as JSON: /api/errors/c72d4f7bf4eb5058.
Report an issue: GitHub.
Appendix: source
Thrown at crates/core/src/host/wasmtime/wasm_instance_env.rs:1827
for view_call in views_for_refresh {
let res: anyhow::Result<()> = (|| {
let resolved = crate::host::module_host::resolve_view_for_refresh(
tx.as_ref().expect("procedure tx missing during view refresh"),
&module_def,
&view_call,
)?;
let table_id = resolved.table_id;
let view_def = resolved.view_def;
let view_name = &resolved.view_name;
let fn_ptr = resolved.global_fn_ptr;
let sender = tx
.as_ref()
.expect("procedure tx missing while looking up refreshed view args")
.view_instance_args(&view_call)
.ok_or_else(|| {
anyhow!(
"failed to look up materialized view args for view {}",
view_call.view_id
)
})?
.sender();
let current_tx = tx.take().expect("procedure tx missing during view refresh");
let (next_tx, call_result) = tx_slot.set(current_tx, || {
Self::call_view(caller, &view_call, view_name, fn_ptr, sender)
});
tx = Some(next_tx);
let return_data = call_result?;
let typespace = resolved.owning_def.typespace();
let row_product_type = typespace
.resolve(view_def.product_type_ref)
.resolve_refs()?
.into_product()View on GitHub (pinned to eddf9f5014)