clockworklabs/SpacetimeDB · error
Local module inspector returned invalid schema data
Error message
Local module inspector returned invalid schema data
What it means
After the inspector child exits successfully, its raw JSON stdout is deserialized into SerdeWrapper<RawModuleDef>. If serde_json::from_slice fails, the output is not the expected schema JSON (and per the code comment, diagnostics are deliberately suppressed so schema literals never echo), yielding this generic error.
Solutions
- Reinstall/refresh the extractor binary so CLI and inspector versions match (rerun publish or update the CLI).
- Ensure the module/build does not print anything to stdout during inspection (use stderr for logs).
- Retry to rule out truncated I/O.
- Capture the extractor's exit status and stderr for debugging if it persists.
Example fix
// before
console.log("loading module..."); // pollutes stdout
// after
console.error("loading module..."); Defensive patterns
Strategy: validation
Validate before calling
if (!/^\s*\{/.test(inspectorStdout)) throw new Error('Inspector did not output JSON; check for stdout logging in module host'); Try / catch
let raw: RawModuleDef; match serde_json::from_slice(&out) { Ok(v) => raw = v.0, Err(_) => bail!("inspect stdout was not schema JSON; check extractor version") } Prevention
- Never print debug logs to stdout in module host code
- Keep CLI and extractor binary versions in sync
- Reinstall the extractor binary after upgrading SpacetimeDB
When it happens
Trigger: The inspector process wrote malformed, empty, or non-JSON output to stdout despite exiting with status 0 — e.g. version mismatch between CLI and extractor binary, corrupted output truncation, or stray prints on stdout.
Common situations: Mismatched extractor_binary/CLI versions after an upgrade; extractor binary replaced or corrupted; module host (JS/WASM) printing debug logs to stdout instead of stderr.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- heterogeneous array
- Local module schema inspection failed
- Local module schema inspection timed out
- unable to decode args
- unable to encode view return value
AI-assisted analysis of clockworklabs/SpacetimeDB@eddf9f5014 (2026-09-20).
Data as JSON: /api/errors/9bab48025a2506cd.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/schema_extract.rs:170
let status = child.wait().await.context("Cannot reap local module inspector")?;
observation.reaped(status);
ensure!(status.success(), "Local module schema inspection failed");
Ok(())
}) => result.unwrap_or_else(|_| Err(anyhow::anyhow!("Local module schema inspection timed out"))),
};
if result.is_err() {
// Queue termination, then retain ownership through positive reaping.
let _ = child.start_kill();
let status = child
.wait()
.await
.context("Cannot reap failed local module inspector")?;
observation.reaped(status);
}
result?;
// Neither parser nor validation diagnostics may echo schema literals.
let SerdeWrapper::<RawModuleDef>(raw) = serde_json::from_slice(&output)
.map_err(|_| anyhow::anyhow!("Local module inspector returned invalid schema data"))?;
let schema =
ModuleDef::try_from(raw).map_err(|_| anyhow::anyhow!("Local module schema validation failed"))?;
Ok(schema)
}
.await;
let _ = send.send(result);
});
(&mut recv).await.context("Local module inspection owner failed")?
}
#[cfg(test)]
mod tests;
View on GitHub (pinned to eddf9f5014)