clockworklabs/SpacetimeDB · critical

v2 subscriptions without a module host are not supported yet

Error message

v2 subscriptions without a module host are not supported yet

What it means

The subscription actor's add_v2_subscription takes `host: Option<&ModuleHost>` and delegates ws_v2 Subscribe messages to the module host, because v2 subscriptions execute module view code. When the actor holds no ModuleHost for the database, the None arm panics ('not supported yet'). The panic happens server-side while processing a client subscribe, instead of returning a DBError to the client, so the actor task crashes.

Solutions

  1. Publish a module for the database and confirm the host is running (`spacetime logs`, server status) before clients subscribe.
  2. Retry the subscription client-side with backoff until the module host is available.
  3. Ensure the client SDK's subscription protocol version is supported by the server/database state.
  4. Upgrade spacetimedb: newer builds convert this into a structured client error instead of a panic.
Defensive patterns

Strategy: validation

Validate before calling

// client: only issue v2 subscribes once the module host is live
// (adapt the status check to your SDK's database info API)
const status = await server.getDatabaseStatus(dbId);
if (status?.moduleHostState !== 'running') {
  throw new Error(`module host not running (${status?.moduleHostState}); publish before subscribing`);
}
await client.subscription.subscribe(dbId, queries); // v2 path

Prevention

When it happens

Trigger: A client sends a ws_v2 Subscribe for a database whose ModuleHost is absent: database created but no module published yet, host still initializing after publish, or the host not yet spawned when the subscribe arrives.

Common situations: Clients subscribing immediately after server start or publish before the module host is live; empty databases that never had a module; client libraries defaulting to the v2 subscription protocol against a database in that state.

Related errors


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

Appendix: source

Thrown at crates/core/src/subscription/module_subscription_actor.rs:1374

        )
    }

    /// Add a subscription consisting of multiple queries.
    ///
    /// Read more in [`Self::add_single_subscription`].
    #[tracing::instrument(level = "trace", skip_all)]
    pub async fn add_v2_subscription(
        &self,
        host: Option<&ModuleHost>,
        sender: Arc<ClientConnectionSender>,
        auth: AuthCtx,
        request: ws_v2::Subscribe,
        timer: Instant,
        _assert: Option<AssertTxFn>,
    ) -> Result<Option<ExecutionMetrics>, DBError> {
        match host {
            Some(host) => host.call_view_add_v2_subscription(sender, auth, request, timer).await,
            None => panic!("v2 subscriptions without a module host are not supported yet"),
        }
    }

    /// Add multiple query sets in one atomic step, in response to a
    /// [`ws_v2::SubscribeBatch`] message.
    ///
    /// Every set is registered under a single subscription-manager lock and
    /// evaluated at a single transaction offset, so no transaction update
    /// for any of the new sets can precede the [`ws_v2::SubscribeBatchApplied`]
    /// response, and updates resume after it, all relative to that same offset.
    ///
    /// A set which fails to compile or evaluate reports a per-set error in the
    /// response while the remaining sets still apply.
    #[tracing::instrument(level = "trace", skip_all)]
    pub async fn add_batch_subscription(
        &self,
        host: Option<&ModuleHost>,
        sender: Arc<ClientConnectionSender>,

View on GitHub (pinned to eddf9f5014)