{"record":{"id":"dd134e16364422b7","repo":"clockworklabs/SpacetimeDB","slug":"procedure-sleep-until-is-only-available-in-async-i","errorCode":null,"errorMessage":"procedure_sleep_until is only available in async instances","messagePattern":"procedure_sleep_until 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":130,"sourceCode":"fn link_sync_stub_for_async_function(\n    linker: &mut Linker<WasmInstanceEnv>,\n    module: &'static str,\n    name: &'static str,\n) -> anyhow::Result<()> {\n    match name {\n        \"procedure_sleep_until\" => {\n            linker.func_wrap(module, name, procedure_sleep_until_sync_stub)?;\n        }\n        \"procedure_http_request\" => {\n            linker.func_wrap(module, name, procedure_http_request_sync_stub)?;\n        }\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;","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/core/src/host/wasmtime/wasmtime_module.rs#L112-L148","documentation":"The wasmtime host registers no-op sync stubs for async-only ABI imports so linking of mismatched modules succeeds, but calling the stub always bails. procedure_sleep_until (the scheduling/timelock primitive) requires an async module instance; when a module that imports it is instantiated in sync mode, the host call fails with this message at reducer runtime.","triggerScenarios":"A module importing the sleep/scheduling host function running in an instance without async support -- classically an SDK-to-server version mismatch where the module's ABI expects async host support that the running instance mode does not provide.","commonSituations":"Upgrading the spacetimedb server but not the spacetimedb crate (or vice versa); publishing a stale prebuilt .wasm against a newer server; mixing dev and release builds between build and deploy machines.","solutions":["Rebuild the module against the spacetimedb crate version matching the server: update Cargo.toml, `cargo clean`, `spacetime build`","Republish the freshly built module","Pin SDK and server to the same version in CI so they upgrade together","Only use sleep/scheduling APIs in modules targeting async instances per current docs"],"exampleFix":"# before: stale module traps on sleep in a sync instance\n# after: align crate version with the server, rebuild, republish\n# Cargo.toml: spacetimedb = \"<server-version>\"\n$ cargo clean && spacetime build --project-path . && 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":["Upgrade the spacetimedb crate and server together, always","cargo clean + full rebuild when either side changes major/minor version","Publish artifacts built by the same pipeline that pins the server version","Treat unexpected traps on host calls as ABI drift and check versions first"],"tags":["wasm","runtime","async","abi-mismatch","wasmtine-host"],"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"}