{"record":{"id":"2d1563abefbfc839","repo":"clockworklabs/SpacetimeDB","slug":"call-procedure-dunder-returned-unexpected-code","errorCode":null,"errorMessage":"{CALL_PROCEDURE_DUNDER} returned unexpected code {code}. Procedures should return code 0 or trap.","messagePattern":"(.+?) returned unexpected code (.+?)\\. Procedures should return code 0 or trap\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/core/src/host/wasmtime/wasmtime_module.rs","lineNumber":812,"sourceCode":"                    conn_id_0,\n                    conn_id_1,\n                    op.timestamp.to_micros_since_unix_epoch() as u64,\n                    args_source.0,\n                    result_sink,\n                ),\n            )\n            .await;\n\n        // Close any ongoing anonymous transactions by aborting them,\n        // in case of improper ABI use (start but no commit/abort).\n        store.data_mut().terminate_dangling_anon_tx();\n\n        // Close the timing span for this procedure and get the BSATN bytes of its result.\n        let (stats, result_bytes) = finish_opcall(store, budget, result_sink);\n\n        let call_result = call_result.and_then(|code| {\n            (code == 0).then_some(result_bytes.into()).ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"{CALL_PROCEDURE_DUNDER} returned unexpected code {code}. Procedures should return code 0 or trap.\"\n                )\n            })\n        });\n\n        let res = module_host_actor::ProcedureExecuteResult { stats, call_result };\n\n        // Take the last tx offset.\n        // Only commits for anonymous transactions currently cause this to advance.\n        let tx_offset = store.data_mut().take_procedure_tx_offset();\n\n        (res, tx_offset)\n    }\n\n    #[tracing::instrument(level = \"trace\", skip_all)]\n    async fn call_http_handler(\n        &mut self,\n        op: module_host_actor::HttpHandlerOp,","sourceCodeStart":794,"sourceCodeEnd":830,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/core/src/host/wasmtime/wasmtime_module.rs#L794-L830","documentation":"Error \"{CALL_PROCEDURE_DUNDER} returned unexpected code {code}. Procedures should return code 0 or trap.\" thrown in clockworklabs/SpacetimeDB.","triggerScenarios":"Thrown at crates/core/src/host/wasmtime/wasmtime_module.rs:812 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}