{"record":{"id":"f7832349e3193cc8","repo":"clockworklabs/SpacetimeDB","slug":"local-module-schema-exceeds-output-limit","errorCode":null,"errorMessage":"Local module schema exceeds output limit","messagePattern":"Local module schema exceeds output limit","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/schema_extract.rs","lineNumber":151,"sourceCode":"                .stdin(Stdio::null())\n                .stdout(Stdio::piped())\n                .stderr(Stdio::null())\n                .kill_on_drop(true);\n            configure_inspector_environment(&mut command);\n            let mut child = command.spawn().context(\"Cannot start local module schema inspection\")?;\n            observation.started(child.id());\n            let mut output = Vec::new();\n            let mut stdout = child\n                .stdout\n                .take()\n                .context(\"Module inspection stdout unavailable\")?\n                .take(MAX_SCHEMA_BYTES + 1);\n            let result = tokio::select! {\n                biased;\n                _ = send.closed() => Err(anyhow::anyhow!(\"Module inspection cancelled\")),\n                result = tokio::time::timeout(deadline, async {\n                    stdout.read_to_end(&mut output).await.context(\"Cannot read local module schema\")?;\n                    ensure!(output.len() as u64 <= MAX_SCHEMA_BYTES, \"Local module schema exceeds output limit\");\n                    let status = child.wait().await.context(\"Cannot reap local module inspector\")?;\n                    observation.reaped(status);\n                    ensure!(status.success(), \"Local module schema inspection failed\");\n                    Ok(())\n                }) => result.unwrap_or_else(|_| Err(anyhow::anyhow!(\"Local module schema inspection timed out\"))),\n            };\n            if result.is_err() {\n                // Queue termination, then retain ownership through positive reaping.\n                let _ = child.start_kill();\n                let status = child\n                    .wait()\n                    .await\n                    .context(\"Cannot reap failed local module inspector\")?;\n                observation.reaped(status);\n            }\n            result?;\n            // Neither parser nor validation diagnostics may echo schema literals.\n            let SerdeWrapper::<RawModuleDef>(raw) = serde_json::from_slice(&output)","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/cli/src/schema_extract.rs#L133-L169","documentation":"When inspecting a locally-run module for its schema, the CLI reads the inspector's stdout capped at `MAX_SCHEMA_BYTES + 1` and throws if the schema output exceeds `MAX_SCHEMA_BYTES`. This bounds memory usage of the local inspection subprocess; oversized output aborts inspection instead of buffering unboundedly.","triggerScenarios":"Running local module inspection (`inspect_observed`, via `inspect_with`) where the module's schema JSON printed to stdout is larger than `MAX_SCHEMA_BYTES` — typically a module with a very large number of tables/reducers/types.","commonSituations":"Auto-generated or codegen-heavy modules declaring thousands of tables; schema output including verbose debug info; accidentally invoking the inspector against the wrong binary that dumps non-schema data.","solutions":["Reduce schema size: consolidate or remove auto-generated tables/reducers/types from the module before inspection.","Check that the inspector command targets the correct module binary and that nothing else writes to stdout in the inspector path.","Inspect only the needed subset of the schema (filter tables/reducers) if the extraction tooling allows scoping.","If legitimately large schemas are needed, request a higher `MAX_SCHEMA_BYTES` in the tooling or use server-side inspection instead of the local capped path."],"exampleFix":"// before: module emits entire schema, exceeds MAX_SCHEMA_BYTES\n// after: scope extraction to the tables you need\n//   or trim generated schema before inspection\nlet schema = extract_schema_filter(&module, /* tables: */ [\"users\", \"orders\"]);","handlingStrategy":"validation","validationCode":"// estimate schema size before running local inspection\n// e.g. count declared tables/reducers at compile time or via the build script\nif schema_table_count > MAX_SCHEMA_TABLES_HINT {\n    // scope extraction to needed tables first\n}","typeGuard":null,"tryCatchPattern":"match inspect_observed(...) {\n    Ok(observation) => use_schema(observation),\n    Err(e) if e.to_string().contains(\"exceeds output limit\") => scope_extraction_smaller(),\n    Err(e) => return Err(e),\n}","preventionTips":["Keep generated schemas lean; avoid codegen-heavy table explosion","Scope schema extraction to needed tables when possible","Ensure the inspector subprocess writes only schema JSON to stdout"],"tags":["rust","cli","output-limit","wasm"],"backgroundTag":"payload-too-large","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"}