{"record":{"id":"7d910608ed4f1cb7","repo":"clockworklabs/SpacetimeDB","slug":"subscription-not-found-subscription-id","errorCode":null,"errorMessage":"Subscription not found: {subscription_id:?}","messagePattern":"Subscription not found: (.+?)","errorType":"exception","errorClass":"DBError::Other","httpStatus":null,"severity":"error","filePath":"crates/core/src/subscription/module_subscription_manager.rs","lineNumber":854,"sourceCode":"    }\n\n    /// Remove a single subscription for a client.\n    /// This will return an error if the client does not have a subscription with the given query id.\n    pub fn remove_subscription(&mut self, client_id: ClientId, query_id: ClientQueryId) -> Result<Vec<Query>, DBError> {\n        let subscription_id = (client_id, query_id);\n        let Some(ci) = self\n            .clients\n            .get_mut(&client_id)\n            .filter(|ci| !ci.dropped.load(Ordering::Acquire))\n        else {\n            return Err(anyhow::anyhow!(\"Client not found: {client_id:?}\").into());\n        };\n\n        #[cfg(test)]\n        ci.assert_ref_count_consistency();\n\n        let Some(query_hashes) = ci.v1_subscriptions.remove(&subscription_id) else {\n            return Err(anyhow::anyhow!(\"Subscription not found: {subscription_id:?}\").into());\n        };\n        let mut queries_to_return = Vec::new();\n        for hash in query_hashes {\n            let remaining_refs = {\n                let Some(count) = ci.subscription_ref_count.get_mut(&hash) else {\n                    return Err(anyhow::anyhow!(\"Query count not found for query hash: {hash:?}\").into());\n                };\n                *count -= 1;\n                *count\n            };\n            if remaining_refs > 0 {\n                // The client is still subscribed to this query, so we are done for now.\n                continue;\n            }\n            // The client is no longer subscribed to this query.\n            ci.subscription_ref_count.remove(&hash);\n            let Some(query_state) = self.queries.get_mut(&hash) else {\n                return Err(anyhow::anyhow!(\"Query state not found for query hash: {hash:?}\").into());","sourceCodeStart":836,"sourceCodeEnd":872,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/core/src/subscription/module_subscription_manager.rs#L836-L872","documentation":"Error \"Subscription not found: {subscription_id:?}\" thrown in clockworklabs/SpacetimeDB.","triggerScenarios":"Thrown at crates/core/src/subscription/module_subscription_manager.rs:854 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}