{"record":{"id":"2e1649da77cd1c34","repo":"clockworklabs/SpacetimeDB","slug":"no-such-module","errorCode":null,"errorMessage":"no such module","messagePattern":"no such module","errorType":"exception","errorClass":"DBError::Other","httpStatus":null,"severity":"error","filePath":"crates/core/src/host/module_host.rs","lineNumber":2065,"sourceCode":"    pub(in crate::host) fn record_view_command_round_trip(info: &ModuleInfo, metric: ViewCommandMetric) {\n        match metric.workload {\n            WorkloadType::Subscribe => info\n                .metrics\n                .request_round_trip_subscribe\n                .observe(metric.timer.elapsed().as_secs_f64()),\n            WorkloadType::Unsubscribe => info\n                .metrics\n                .request_round_trip_unsubscribe\n                .observe(metric.timer.elapsed().as_secs_f64()),\n            _ => {}\n        }\n    }\n\n    async fn call_sql_command(&self, cmd: SqlCommand) -> Result<SqlCommandResult, DBError> {\n        call_instance!(self, \"call_sql\", cmd, |cmd, inst| inst.call_sql(cmd), |cmd, inst| inst\n            .call_sql(cmd)\n            .await,)\n        .map_err(|_| DBError::Other(anyhow::anyhow!(\"no such module\")))\n    }\n\n    pub async fn disconnect_client(&self, client_id: ClientActorId) {\n        log::trace!(\"disconnecting client {client_id}\");\n        if let Err(e) = call_instance!(\n            self,\n            \"disconnect_client\",\n            client_id,\n            |client_id, inst| inst.disconnect_client(client_id),\n            |client_id, inst| inst.disconnect_client(client_id).await,\n        ) {\n            log::error!(\"Error from client_disconnected transaction: {e}\");\n        }\n    }\n\n    pub fn disconnect_client_inner(\n        client_id: ClientActorId,\n        info: &ModuleInfo,","sourceCodeStart":2047,"sourceCodeEnd":2083,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/core/src/host/module_host.rs#L2047-L2083","documentation":"Thrown by ModuleHost::call_sql_command when the call_instance! dispatch cannot find a live module instance to run `call_sql` on; any dispatch failure is collapsed into DBError::Other(\"no such module\"). The host keeps one instantiated module per database, so this means no module instance is currently running for that database: it was never published, failed to start, crashed, or is mid-replacement during an update. It is a lifecycle error, not a SQL error: the statement never reached an executor.","triggerScenarios":"Calling call_sql against a database whose instance is absent: (1) no module published at that address; (2) publish finished but instance startup is still in flight; (3) the instance died (panic/trap) and a replacement has not registered; (4) a database update temporarily removed the old instance before the new one is up.","commonSituations":"Scripts issuing SQL immediately after publish without waiting for module startup; clients pointed at the wrong database address; deploying a module that compiles but fails at startup so the instance never registers; host/module version skew after an upgrade.","solutions":["Verify the module is actually running: check publish output and host logs for the database address and successful module startup.","Wait for module readiness (poll a trivial call or the host's module info) and retry the SQL command.","If startup failed, inspect module logs, fix the startup error, and republish.","Confirm the database address/identity used by the caller matches the one the module was published to."],"exampleFix":"// before: fire SQL right after publish\npublish(module).await;\nhost.call_sql_command(cmd).await?; // \"no such module\"\n\n// after: gate on module readiness first\npublish(module).await;\nwait_for_module_running(&host, database_address).await?;\nhost.call_sql_command(cmd).await?;","handlingStrategy":"retry","validationCode":"// Gate SQL traffic on module readiness instead of racing instance startup.\n// Poll the host module-info endpoint (or a trivial subscription) until running:\nwhile !client.module_info(address).await?.is_running {\n    tokio::time::sleep(Duration::from_millis(100)).await;\n}","typeGuard":null,"tryCatchPattern":"match host.call_sql_command(cmd).await {\n    Err(e @ DBError::Other(_)) if e.to_string().contains(\"no such module\") => {\n        // instance not up (yet) — wait for readiness and retry with backoff\n        retry_with_backoff(|| host.call_sql_command(cmd.clone())).await\n    }\n    other => other,\n}","preventionTips":["Wait for publish and module startup to complete before issuing SQL commands.","Point clients at the exact database address the module was published to.","Monitor module logs so a crashed instance is noticed before clients hit it."],"tags":["module-lifecycle","sql","instance-not-running","spacetimedb"],"backgroundTag":"module-not-found","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}