{"record":{"id":"c2f0a436d88fa920","repo":"clockworklabs/SpacetimeDB","slug":"v2-subscriptions-without-a-module-host-are-not-sup","errorCode":null,"errorMessage":"v2 subscriptions without a module host are not supported yet","messagePattern":"v2 subscriptions without a module host are not supported yet","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/core/src/subscription/module_subscription_actor.rs","lineNumber":1374,"sourceCode":"        )\n    }\n\n    /// Add a subscription consisting of multiple queries.\n    ///\n    /// Read more in [`Self::add_single_subscription`].\n    #[tracing::instrument(level = \"trace\", skip_all)]\n    pub async fn add_v2_subscription(\n        &self,\n        host: Option<&ModuleHost>,\n        sender: Arc<ClientConnectionSender>,\n        auth: AuthCtx,\n        request: ws_v2::Subscribe,\n        timer: Instant,\n        _assert: Option<AssertTxFn>,\n    ) -> Result<Option<ExecutionMetrics>, DBError> {\n        match host {\n            Some(host) => host.call_view_add_v2_subscription(sender, auth, request, timer).await,\n            None => panic!(\"v2 subscriptions without a module host are not supported yet\"),\n        }\n    }\n\n    /// Add multiple query sets in one atomic step, in response to a\n    /// [`ws_v2::SubscribeBatch`] message.\n    ///\n    /// Every set is registered under a single subscription-manager lock and\n    /// evaluated at a single transaction offset, so no transaction update\n    /// for any of the new sets can precede the [`ws_v2::SubscribeBatchApplied`]\n    /// response, and updates resume after it, all relative to that same offset.\n    ///\n    /// A set which fails to compile or evaluate reports a per-set error in the\n    /// response while the remaining sets still apply.\n    #[tracing::instrument(level = \"trace\", skip_all)]\n    pub async fn add_batch_subscription(\n        &self,\n        host: Option<&ModuleHost>,\n        sender: Arc<ClientConnectionSender>,","sourceCodeStart":1356,"sourceCodeEnd":1392,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/core/src/subscription/module_subscription_actor.rs#L1356-L1392","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Publish a module for the database and confirm the host is running (`spacetime logs`, server status) before clients subscribe.","Retry the subscription client-side with backoff until the module host is available.","Ensure the client SDK's subscription protocol version is supported by the server/database state.","Upgrade spacetimedb: newer builds convert this into a structured client error instead of a panic."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// client: only issue v2 subscribes once the module host is live\n// (adapt the status check to your SDK's database info API)\nconst status = await server.getDatabaseStatus(dbId);\nif (status?.moduleHostState !== 'running') {\n  throw new Error(`module host not running (${status?.moduleHostState}); publish before subscribing`);\n}\nawait client.subscription.subscribe(dbId, queries); // v2 path","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Publish the module and wait for it to become healthy before clients subscribe.","Gate v2 subscription usage on a confirmed module deployment.","Add reconnect-with-backoff so clients that race a module update resubscribe once the host is back.","Avoid subscribing to databases that intentionally have no module."],"tags":["spacetimedb","subscription","websocket","module-host","panic"],"backgroundTag":"missing-module-host","analyzedSha":"eddf9f5014579a50d4b67630e28b6e15cad9c4af","analyzedAt":"2026-09-20T12:15:59.611Z","contentChangedAt":"2026-09-20T12:15:59.611Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}