{"record":{"id":"0261ff4f6fc4c690","repo":"clockworklabs/SpacetimeDB","slug":"procedure-http-request-is-only-available-in-async","errorCode":null,"errorMessage":"procedure_http_request is only available in async instances","messagePattern":"procedure_http_request is only available in async instances","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/core/src/host/wasmtime/wasmtime_module.rs","lineNumber":141,"sourceCode":"        }\n        _ => anyhow::bail!(\"missing sync Wasmtime stub for async ABI import `{module}::{name}`\"),\n    }\n    Ok(())\n}\n\nfn procedure_sleep_until_sync_stub(_: Caller<'_, WasmInstanceEnv>, _: i64) -> anyhow::Result<i64> {\n    anyhow::bail!(\"procedure_sleep_until is only available in async instances\")\n}\n\nfn procedure_http_request_sync_stub(\n    _: Caller<'_, WasmInstanceEnv>,\n    _: u32,\n    _: u32,\n    _: u32,\n    _: u32,\n    _: u32,\n) -> anyhow::Result<u32> {\n    anyhow::bail!(\"procedure_http_request is only available in async instances\")\n}\n\nmacro_rules! impl_wasmtime_module {\n    ($module:ty) => {\n        impl module_host_actor::WasmModule for $module {\n            type Instance = WasmtimeInstance;\n            type InstancePre = Self;\n            type ExternType = ExternType;\n\n            fn get_export(&self, s: &str) -> Option<Self::ExternType> {\n                self.module\n                    .module()\n                    .exports()\n                    .find(|exp| exp.name() == s)\n                    .map(|exp| exp.ty())\n            }\n\n            fn for_each_export<E>(&self, mut f: impl FnMut(&str, &Self::ExternType) -> Result<(), E>) -> Result<(), E> {","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/core/src/host/wasmtime/wasmtime_module.rs#L123-L159","documentation":"Same mechanism as the sleep stub: the wasmtime host links async-only imports (here spacetimedb's HTTP request procedure) to stubs that always fail when called from a synchronous instance. procedure_http_request needs an async instance (network I/O requires the host's async support), so a module invoking it in sync mode gets this error from the stub at call time.","triggerScenarios":"A module performing host-side HTTP requests (e.g. via the SDK's HTTP API) but instantiated in sync mode -- typically after upgrading only one of the SDK or server, so the module's ABI and the instance mode disagree.","commonSituations":"Calling out to external APIs from a reducer built with a mismatched SDK version; publishing an old artifact to an upgraded server; local dev server older than the crate used to build.","solutions":["Rebuild the module with the spacetimedb crate version matching the server (cargo update / Cargo.toml pin), then `cargo clean && spacetime build`","Republish the rebuilt module","Keep SDK and server versions locked together in your toolchain","If you don't need outbound HTTP, remove the call so the import is not generated"],"exampleFix":"# before: stale module calls spacetimedb_http_request in a sync instance\n# after: rebuild with the SDK matching the server, republish\n$ cargo update -p spacetimedb --precise <server-version>\n$ cargo clean && spacetime build && spacetime publish my-db","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# fail if SDK and server versions drift\nsdk=$(grep -A1 'spacetimedb =' Cargo.toml | grep -o '\"[^\"]*\"' | tr -d '\"' | head -1)\n[ \"$sdk\" = \"$SPACETIMEDB_VERSION\" ] \\\n  || { echo \"SDK $sdk != server $SPACETIMEDB_VERSION - rebuild module\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep SDK and server versions in lockstep in CI","Rebuild and republish modules after any server upgrade before exercising HTTP features","Remove unused outbound-HTTP call sites so the import is never generated","Version-stamp built artifacts so stale .wasm files are detectable"],"tags":["wasm","runtime","async","http","abi-mismatch"],"backgroundTag":"wasm-abi-version-mismatch","analyzedSha":"eddf9f5014579a50d4b67630e28b6e15cad9c4af","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}