{"record":{"id":"be3bce99067c8e25","repo":"clockworklabs/SpacetimeDB","slug":"call-view-dunder-export-is-a-function-with-incor","errorCode":null,"errorMessage":"{CALL_VIEW_DUNDER} export is a function with incorrect type: {err}","messagePattern":"(.+?) export is a function with incorrect type: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/core/src/host/wasmtime/wasmtime_module.rs","lineNumber":471,"sourceCode":"        export\n            .into_func()\n            .unwrap_or_else(|| panic!(\"{CALL_PROCEDURE_DUNDER} export is not a function\"))\n            .typed(store)\n            .unwrap_or_else(|err| panic!(\"{CALL_PROCEDURE_DUNDER} export is a function with incorrect type: {err}\")),\n    )\n}\n\n/// Look up the `instance`'s export named by [`CALL_VIEW_DUNDER`].\n///\n/// Similar to [`get_call_procedure`], but for views.\nfn get_call_view(store: &mut Store<WasmInstanceEnv>, instance: &Instance) -> Option<CallViewType> {\n    let export = instance.get_export(store.as_context_mut(), CALL_VIEW_DUNDER)?;\n    Some(\n        export\n            .into_func()\n            .unwrap_or_else(|| panic!(\"{CALL_VIEW_DUNDER} export is not a function\"))\n            .typed(store)\n            .unwrap_or_else(|err| panic!(\"{CALL_VIEW_DUNDER} export is a function with incorrect type: {err}\")),\n    )\n}\n\n/// Look up the `instance`'s export named by [`CALL_VIEW_ANON_DUNDER`].\n///\n/// Similar to [`get_call_procedure`], but for anonymous views.\nfn get_call_view_anon(store: &mut Store<WasmInstanceEnv>, instance: &Instance) -> Option<CallViewAnonType> {\n    let export = instance.get_export(store.as_context_mut(), CALL_VIEW_ANON_DUNDER)?;\n    Some(\n        export\n            .into_func()\n            .unwrap_or_else(|| panic!(\"{CALL_VIEW_ANON_DUNDER} export is not a function\"))\n            .typed(store)\n            .unwrap_or_else(|err| panic!(\"{CALL_VIEW_ANON_DUNDER} export is a function with incorrect type: {err}\")),\n    )\n}\n\n/// Look up the `instance`'s export named by [`CALL_HTTP_HANDLER_DUNDER`].","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/core/src/host/wasmtime/wasmtime_module.rs#L453-L489","documentation":"The `__call_view__` export is a function, but `TypedFunc::typed` rejects it because its parameters/results do not match `CallViewType`, so the host panics. This indicates the view entry ABI (query/view id, sender and argument encoding, return encoding) differs from what this server build expects. Like the other dunder-export panics, it is a module/host version mismatch rather than a bug in the view query itself.","triggerScenarios":"Publishing or instantiating a module whose `__call_view__` function signature differs from the TypedFunc signature the running server binds (e.g. extra/missing params after an SDK upgrade changed the view calling convention).","commonSituations":"Server upgraded while the module artifact was built by an older SDK; modules built in CI with a cached toolchain; SDK releases that changed the view entry signature.","solutions":["Rebuild and republish the module with the SDK/CLI matching the server version.","Diff the export signature with `wasm2wat module.wasm | grep -A5 __call_view__` against a module freshly generated by the current SDK.","Clear build caches (target/, CI cache) so an old artifact cannot be republished.","Check the spacetimedb changelog for view-ABI changes between your module's SDK and the server."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"use wasmtime::{Engine, Module, ExternType};\n\nfn view_export_well_formed(engine: &Engine, wasm: &[u8]) -> Result<(), String> {\n    let module = Module::new(engine, wasm).map_err(|e| e.to_string())?;\n    if let Some(exp) = module.get_export(\"__call_view__\") {\n        if !matches!(exp.ty(), ExternType::Func(func_ty) if func_ty.params().len() > 0) {\n            return Err(\"__call_view__ must be a function with the server's view ABI\".into());\n        }\n    }\n    Ok(())\n}","typeGuard":"fn is_func_export(ty: &ExternType) -> bool { matches!(ty, ExternType::Func(_)) }","tryCatchPattern":"if std::panic::catch_unwind(instantiate).is_err() {\n    // check the panic message for \"__call_view__\" and rebuild the module against the matching SDK\n}","preventionTips":["Rebuild modules together with server upgrades in one pipeline step.","Diff wasm2wat output of the dunder exports before and after SDK upgrades.","Keep one reference module per SDK version to compare export signatures."],"tags":["wasm","wasmtime","abi-mismatch","views","spacetimedb"],"backgroundTag":"wasm-abi-mismatch","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}