clockworklabs/SpacetimeDB · error · anyhow::Error

procedure_sleep_until is only available in async instances

Error message

procedure_sleep_until is only available in async instances

What it means

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.

Solutions

  1. Rebuild the module against the spacetimedb crate version matching the server: update Cargo.toml, `cargo clean`, `spacetime build`
  2. Republish the freshly built module
  3. Pin SDK and server to the same version in CI so they upgrade together
  4. Only use sleep/scheduling APIs in modules targeting async instances per current docs

Example fix

# before: stale module traps on sleep in a sync instance
# after: align crate version with the server, rebuild, republish
# Cargo.toml: spacetimedb = "<server-version>"
$ cargo clean && spacetime build --project-path . && spacetime publish my-db
Defensive patterns

Strategy: validation

Validate before calling

#!/usr/bin/env bash
# fail if SDK and server versions drift
sdk=$(grep -A1 'spacetimedb =' Cargo.toml | grep -o '"[^"]*"' | tr -d '"' | head -1)
[ "$sdk" = "$SPACETIMEDB_VERSION" ] \
  || { echo "SDK $sdk != server $SPACETIMEDB_VERSION - rebuild module" >&2; exit 1; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@eddf9f5014 (2026-08-20). Data as JSON: /api/errors/dd134e16364422b7. Report an issue: GitHub.

Appendix: source

Thrown at crates/core/src/host/wasmtime/wasmtime_module.rs:130

fn link_sync_stub_for_async_function(
    linker: &mut Linker<WasmInstanceEnv>,
    module: &'static str,
    name: &'static str,
) -> anyhow::Result<()> {
    match name {
        "procedure_sleep_until" => {
            linker.func_wrap(module, name, procedure_sleep_until_sync_stub)?;
        }
        "procedure_http_request" => {
            linker.func_wrap(module, name, procedure_http_request_sync_stub)?;
        }
        _ => anyhow::bail!("missing sync Wasmtime stub for async ABI import `{module}::{name}`"),
    }
    Ok(())
}

fn procedure_sleep_until_sync_stub(_: Caller<'_, WasmInstanceEnv>, _: i64) -> anyhow::Result<i64> {
    anyhow::bail!("procedure_sleep_until is only available in async instances")
}

fn procedure_http_request_sync_stub(
    _: Caller<'_, WasmInstanceEnv>,
    _: u32,
    _: u32,
    _: u32,
    _: u32,
    _: u32,
) -> anyhow::Result<u32> {
    anyhow::bail!("procedure_http_request is only available in async instances")
}

macro_rules! impl_wasmtime_module {
    ($module:ty) => {
        impl module_host_actor::WasmModule for $module {
            type Instance = WasmtimeInstance;
            type InstancePre = Self;

View on GitHub (pinned to eddf9f5014)