{"record":{"id":"f16515766046c502","repo":"clockworklabs/SpacetimeDB","slug":"call-view-anon-dunder-export-is-not-a-function","errorCode":null,"errorMessage":"{CALL_VIEW_ANON_DUNDER} export is not a function","messagePattern":"(.+?) export is not a function","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/core/src/host/wasmtime/wasmtime_module.rs","lineNumber":483,"sourceCode":"    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`].\n///\n/// Similar to [`get_call_procedure`], but for HTTP handlers.\nfn get_call_http_handler(store: &mut Store<WasmInstanceEnv>, instance: &Instance) -> Option<CallHttpHandlerType> {\n    let export = instance.get_export(store.as_context_mut(), CALL_HTTP_HANDLER_DUNDER)?;\n    Some(\n        export\n            .into_func()\n            .unwrap_or_else(|| panic!(\"{CALL_HTTP_HANDLER_DUNDER} export is not a function\"))\n            .typed(store)\n            .unwrap_or_else(|err| panic!(\"{CALL_HTTP_HANDLER_DUNDER} export is a function with incorrect type: {err}\")),\n    )\n}","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/core/src/host/wasmtime/wasmtime_module.rs#L465-L501","documentation":"get_call_view_anon resolves the `__call_view_anon__` export, the entry point for anonymous views. `Export::into_func()` returns None when that name is exported as a memory, global, or table, and the host panics because a non-function entry is unrecoverable. The export is optional (absent name yields None), so the panic only fires when something occupies the name with the wrong kind.","triggerScenarios":"Instantiating a module that exports `__call_view_anon__` as a non-function item (global/memory/table); reached in get_call_view_anon during publish or module host startup.","commonSituations":"Accidental export name collision with the reserved dunder name in module code or WAT; tooling that exports globals with mangled names colliding after a rename; forks that renamed anonymous view entries.","solutions":["Run `wasm-objdump -x module.wasm | grep -A2 __call_view_anon__` to identify the export kind.","Rename or remove the conflicting export in module source and rebuild.","Regenerate the module with the official SDK so only functions carry the dunder names."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"use wasmtime::{Engine, Module, ExternType};\n\nfn anon_view_export_is_func(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_anon__\") {\n        if !matches!(exp.ty(), ExternType::Func(_)) {\n            return Err(format!(\"__call_view_anon__ exported as {:?}, not a function\", exp.ty()));\n        }\n    }\n    Ok(())\n}","typeGuard":"fn is_func_export(ty: &ExternType) -> bool { matches!(ty, ExternType::Func(_)) }","tryCatchPattern":null,"preventionTips":["Reserve dunder export names in code review checklists for module code.","Automate an export-kind scan over built wasm in CI.","Regenerate modules with the official SDK rather than editing exports by hand."],"tags":["wasm","wasmtime","export-kind","anonymous-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"}