{"record":{"id":"6b7a00edd9a54627","repo":"clockworklabs/SpacetimeDB","slug":"local-module-inspection-thread-failed","errorCode":null,"errorMessage":"Local module inspection thread failed","messagePattern":"Local module inspection thread failed","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/schema_extract.rs","lineNumber":42,"sourceCode":"pub(crate) fn from_path(path: &Path) -> anyhow::Result<ModuleDef> {\n    let bytes = read_program(path)?;\n    let host_type = match path.extension().and_then(|ext| ext.to_str()) {\n        Some(\"wasm\") => \"Wasm\",\n        Some(\"js\") => \"Js\",\n        _ => anyhow::bail!(\"Cannot determine module type from file extension\"),\n    };\n    inspect_blocking(extractor_path()?, bytes, host_type.into())\n}\n\nfn inspect_blocking(extractor: PathBuf, bytes: Vec<u8>, host_type: String) -> anyhow::Result<ModuleDef> {\n    std::thread::spawn(move || {\n        tokio::runtime::Builder::new_current_thread()\n            .enable_all()\n            .build()?\n            .block_on(inspect_with(extractor, bytes, host_type, INSPECT_TIMEOUT))\n    })\n    .join()\n    .map_err(|_| anyhow::anyhow!(\"Local module inspection thread failed\"))?\n}\n\npub(crate) fn read_program(path: &std::path::Path) -> anyhow::Result<Vec<u8>> {\n    use std::io::Read;\n    let mut bytes = Vec::new();\n    std::fs::File::open(path)?\n        .take(spacetimedb_client_api_messages::publish::MAX_MODULE_BYTES as u64 + 1)\n        .read_to_end(&mut bytes)?;\n    ensure!(\n        bytes.len() <= spacetimedb_client_api_messages::publish::MAX_MODULE_BYTES,\n        \"Module exceeds publish size limit\"\n    );\n    Ok(bytes)\n}\n\nconst MAX_SCHEMA_BYTES: u64 = 16 * 1024 * 1024;\nconst INSPECT_TIMEOUT: Duration = Duration::from_secs(60);\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/cli/src/schema_extract.rs#L24-L60","documentation":"inspect_blocking runs the module inspector on a spawned OS thread and uses thread::join().map_err(|_| ...). The error fires when the inspection thread itself panicked (JoinError), meaning the local inspection machinery crashed before producing a result — not that the module failed inspection.","triggerScenarios":"Calling from_path (synchronous schema extraction) when the inner std::thread::spawn closure panics — e.g. the tokio current-thread runtime fails to build, or inspect_with panics on the worker thread.","commonSituations":"Environments where tokio runtime construction fails (resource limits), or a bug/panic inside the inspection pipeline; also reproducible in tests that force the inspection thread to panic.","solutions":["Re-run the command; transient thread/runtime failures may not recur.","Inspect server logs / RUST_BACKTRACE to find the panic that killed the inspection thread.","Check memory/thread limits of the environment (CI containers often restrict thread creation).","If reproducible, file/debug the underlying panic in the inspector pipeline; this error masks its real cause."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// CLI: catch the anyhow error, log RUST_BACKTRACE, retry once","preventionTips":["Ensure the environment allows thread creation and has adequate memory","Set RUST_BACKTRACE=1 when debugging local inspection","Keep CLI updated to avoid known panics in the inspect pipeline"],"tags":["cli","threading","panic","rust"],"backgroundTag":"thread-interrupted","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"}