{"record":{"id":"e633513e0fad29ce","repo":"clockworklabs/SpacetimeDB","slug":"getrandom-usage-detected-it-seems-like-either-yo","errorCode":null,"errorMessage":"getrandom usage detected.\n\nIt seems like either you or a crate in your dependency tree is depending on\nthe `getrandom` crate for random number generation. getrandom is the default\nrandomness source for the `rand` crate, and is used when you call\n`rand::random()` or `rand::thread_rng()`. If this is you, you should instead\nuse `ctx.rng()` on a `ReducerContext`. If this is a crate in your\ntree, you should try to see if the crate provides a way to pass in a custom\n`Rng` type, and pass it the rng returned from `ctx.rng()`.","messagePattern":"getrandom usage detected\\.\n\nIt seems like either you or a crate in your dependency tree is depending on\nthe `getrandom` crate for random number generation\\. getrandom is the default\nrandomness source for the `rand` crate, and is used when you call\n`rand::random\\(\\)` or `rand::thread_rng\\(\\)`\\. If this is you, you should instead\nuse `ctx\\.rng\\(\\)` on a `ReducerContext`\\. If this is a crate in your\ntree, you should try to see if the crate provides a way to pass in a custom\n`Rng` type, and pass it the rng returned from `ctx\\.rng\\(\\)`\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/tasks/rust.rs","lineNumber":133,"sourceCode":"    };\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\\\n             `rand::random()` or `rand::thread_rng()`. If this is you, you should instead\\n\\\n             use `ctx.rng()` on a `ReducerContext`. If this is a crate in your\\n\\\n             tree, you should try to see if the crate provides a way to pass in a custom\\n\\\n             `Rng` type, and pass it the rng returned from `ctx.rng()`.\"\n        )\n    }\n    Ok(())\n}\n\nconst WBINDGEN_PREFIX: &str = \"__wbindgen\";\nfn has_wasm_bindgen(module: &wasmbin::Module) -> bool {\n    let check_import = |import: &wasmbin::sections::Import| {\n        import.path.module.starts_with(WBINDGEN_PREFIX) || import.path.name.starts_with(WBINDGEN_PREFIX)","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/tasks/rust.rs#L115-L151","documentation":"Error \"getrandom usage detected.\n\nIt seems like either you or a crate in your dependency tree is depending on\nthe `getrandom` crate for random number generation. getrandom is the default\nrandomness source for the `rand` crate, and is used when you call\n`rand::random()` or `rand::thread_rng()`. If this is you, you should instead\nuse `ctx.rng()` on a `ReducerContext`. If this is a crate in your\ntree, you should try to see if the crate provides a way to pass in a custom\n`Rng` type, and pass it the rng returned from `ctx.rng()`.\" thrown in clockworklabs/SpacetimeDB.","triggerScenarios":"Thrown at crates/cli/src/tasks/rust.rs:133 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}