{"record":{"id":"6d9fa841154c94fc","repo":"clockworklabs/SpacetimeDB","slug":"call-http-handler-dunder-export-is-not-a-functio","errorCode":null,"errorMessage":"{CALL_HTTP_HANDLER_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":497,"sourceCode":"    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}\n\n// `__call_procedure__` takes the same arguments as `__call_reducer__`.\ntype CallProcedureType = CallReducerType;\n\n/// The function signature of `__call_reducer__`\ntype CallReducerType = TypedFunc<\n    (\n        // ReducerId\n        u32,\n        // sender_0\n        u64,\n        // sender_1\n        u64,\n        // sender_2","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/core/src/host/wasmtime/wasmtime_module.rs#L479-L515","documentation":"get_call_http_handler resolves the `__call_http_handler__` export, the entry point invoked when an HTTP request routes to a module handler. If the name is exported as a memory, global, or table, `into_func()` yields None and the host panics. HTTP handler entry is optional (absent name yields None), so the panic only fires when the name is occupied by a non-function.","triggerScenarios":"Instantiating a module that exports `__call_http_handler__` as a non-function item; reached in get_call_http_handler during publish or host startup of a module declaring HTTP handlers.","commonSituations":"Export-name collisions in hand-written code; modules generated by tools that emit globals for handler metadata under the reserved name; partial codegen when the http feature flag is mismatched between SDK and server.","solutions":["Inspect the export kind with `wasm-objdump -x module.wasm | grep -A2 __call_http_handler__`.","Remove or rename the conflicting export and rebuild with the official SDK.","Confirm the SDK's http-handler feature matches the server's supported module ABI version."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"use wasmtime::{Engine, Module, ExternType};\n\nfn http_handler_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_http_handler__\") {\n        if !matches!(exp.ty(), ExternType::Func(_)) {\n            return Err(format!(\"__call_http_handler__ 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":["Do not attach custom exports under reserved dunder names.","Run an export-kind check on built artifacts in CI.","Keep the http-handler feature flags aligned between SDK and server."],"tags":["wasm","wasmtime","export-kind","http-handler","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"}