clockworklabs/SpacetimeDB · error · anyhow::Error
wasm-bindgen detected. It seems like either you or a crate…
Error message
wasm-bindgen detected. It seems like either you or a crate in your dependency tree is depending on wasm-bindgen. wasm-bindgen is only for webassembly modules that target the web platform, and will not work in the context of SpacetimeDB. To find the offending dependency, run `cargo tree -i wasm-bindgen`. Try checking its cargo features for 'js' or 'web' or 'wasm-bindgen' to see if there's a way to disable it.
What it means
After compiling the module, check_for_issues decodes the resulting .wasm with wasmbin and inspects its import section for wasm-bindgen signatures. wasm-bindgen generates JS-bridge imports that only resolve inside a browser host; SpacetimeDB's runtime cannot supply them, so such a module would trap at instantiation. The CLI therefore rejects the artifact at build/publish time and points you at cargo tree to find the culprit in your dependency graph.
Solutions
- Run `cargo tree -i wasm-bindgen` (same target/features as the module build) to see which dependency pulls it in
- Disable the offending feature in Cargo.toml: `default-features = false` or turn off its `js`/`web`/`wasm-bindgen` features
- Replace the crate with a wasm-neutral or no_std alternative
- Rebuild and publish
Example fix
# before (Cargo.toml) -- default features pull wasm-bindgen
some-util = "1.0"
# after
some-util = { version = "1.0", default-features = false }
# verify: cargo tree -i wasm-bindgen -> should report not found Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash
# fail CI if wasm-bindgen enters the module graph
cargo tree -i wasm-bindgen >/dev/null 2>&1 \
&& { echo 'wasm-bindgen detected in dependency tree' >&2; exit 1; } \
|| true Prevention
- Declare wasm-bound deps with default-features = false and re-enable only what you need
- Run `cargo tree -i wasm-bindgen` whenever adding a dependency to a module
- Prefer no_std / wasm-neutral crates in module code
- Keep this check in CI so a transitive upgrade cannot sneak it in
When it happens
Trigger: Publishing a module whose dependency tree pulls in wasm-bindgen when compiled for wasm32-unknown-unknown -- e.g. a dependency with `js`, `web`, or `wasm-bindgen` cargo features enabled by default, or web-oriented library code reused inside the module.
Common situations: Reusing crypto/serialization/utility code from a web project; a crate that switches to a wasm-bindgen backend on wasm32 targets unless default features are disabled; adding a dependency without auditing its wasm feature set.
Related errors
- getrandom usage detected. It seems like either you or a…
- AddColumns: table ` ` not found in new module def
- AddConstraint: ` ` not found in new module def
- AddRowLevelSecurity: RLS
- AddSequence: ` ` not found in new module def
AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20).
Data as JSON: /api/errors/eec4500f25ff63f6.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/tasks/rust.rs:120
}
let artifact = artifact.context("no artifact found?")?;
let artifact = artifact.filenames.into_iter().next().context("no wasm?")?;
check_for_issues(artifact.as_ref())?;
Ok(artifact.into())
}
fn check_for_issues(artifact: &Path) -> anyhow::Result<()> {
// if this fails for some reason, just let it fail elsewhere
let Ok(file) = fs::File::open(artifact) else {
return Ok(());
};
let Ok(module) = wasmbin::Module::decode_from(&mut io::BufReader::new(file)) else {
return Ok(());
};
if has_wasm_bindgen(&module) {
anyhow::bail!(
"wasm-bindgen detected.\n\
\n\
It seems like either you or a crate in your dependency tree is depending on\n\
wasm-bindgen. wasm-bindgen is only for webassembly modules that target the web\n\
platform, and will not work in the context of SpacetimeDB.\n\
\n\
To find the offending dependency, run `cargo tree -i wasm-bindgen`. Try checking\n\
its cargo features for 'js' or 'web' or 'wasm-bindgen' to see if there's a way\n\
to disable it."
)
}
if has_getrandom(&module) {
anyhow::bail!(
"getrandom usage detected.\n\
\n\
It seems like either you or a crate in your dependency tree is depending on\n\
the `getrandom` crate for random number generation. getrandom is the default\n\
randomness source for the `rand` crate, and is used when you call\n\View on GitHub (pinned to 6dee26c6ef)