{"record":{"id":"eec4500f25ff63f6","repo":"clockworklabs/SpacetimeDB","slug":"wasm-bindgen-detected-it-seems-like-either-you-o","errorCode":null,"errorMessage":"wasm-bindgen detected.\n\nIt seems like either you or a crate in your dependency tree is depending on\nwasm-bindgen. wasm-bindgen is only for webassembly modules that target the web\nplatform, and will not work in the context of SpacetimeDB.\n\nTo find the offending dependency, run `cargo tree -i wasm-bindgen`. Try checking\nits cargo features for 'js' or 'web' or 'wasm-bindgen' to see if there's a way\nto disable it.","messagePattern":"wasm-bindgen detected\\.\n\nIt seems like either you or a crate in your dependency tree is depending on\nwasm-bindgen\\. wasm-bindgen is only for webassembly modules that target the web\nplatform, and will not work in the context of SpacetimeDB\\.\n\nTo find the offending dependency, run `cargo tree -i wasm-bindgen`\\. Try checking\nits cargo features for 'js' or 'web' or 'wasm-bindgen' to see if there's a way\nto disable it\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/tasks/rust.rs","lineNumber":120,"sourceCode":"    }\n    let artifact = artifact.context(\"no artifact found?\")?;\n    let artifact = artifact.filenames.into_iter().next().context(\"no wasm?\")?;\n\n    check_for_issues(artifact.as_ref())?;\n\n    Ok(artifact.into())\n}\n\nfn check_for_issues(artifact: &Path) -> anyhow::Result<()> {\n    // if this fails for some reason, just let it fail elsewhere\n    let Ok(file) = fs::File::open(artifact) else {\n        return Ok(());\n    };\n    let Ok(module) = wasmbin::Module::decode_from(&mut io::BufReader::new(file)) else {\n        return Ok(());\n    };\n    if has_wasm_bindgen(&module) {\n        anyhow::bail!(\n            \"wasm-bindgen detected.\\n\\\n             \\n\\\n             It seems like either you or a crate in your dependency tree is depending on\\n\\\n             wasm-bindgen. wasm-bindgen is only for webassembly modules that target the web\\n\\\n             platform, and will not work in the context of SpacetimeDB.\\n\\\n             \\n\\\n             To find the offending dependency, run `cargo tree -i wasm-bindgen`. Try checking\\n\\\n             its cargo features for 'js' or 'web' or 'wasm-bindgen' to see if there's a way\\n\\\n             to disable it.\"\n        )\n    }\n    if has_getrandom(&module) {\n        anyhow::bail!(\n            \"getrandom usage detected.\\n\\\n             \\n\\\n             It seems like either you or a crate in your dependency tree is depending on\\n\\\n             the `getrandom` crate for random number generation. getrandom is the default\\n\\\n             randomness source for the `rand` crate, and is used when you call\\n\\","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/tasks/rust.rs#L102-L138","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before (Cargo.toml) -- default features pull wasm-bindgen\nsome-util = \"1.0\"\n\n# after\nsome-util = { version = \"1.0\", default-features = false }\n# verify: cargo tree -i wasm-bindgen  -> should report not found","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# fail CI if wasm-bindgen enters the module graph\ncargo tree -i wasm-bindgen >/dev/null 2>&1 \\\n  && { echo 'wasm-bindgen detected in dependency tree' >&2; exit 1; } \\\n  || true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["rust","wasm","dependencies","publish","wasm-bindgen"],"backgroundTag":"unsupported-wasm-import-detected","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}