You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
__getrandom_v03_custom Not Preventing wasm-bindgen Import on wasm32-unknown-unknown with Internet Computer #633
Description
Hi, I'm encountering an issue where defining __getrandom_v03_custom as per the documentation (https://docs.rs/getrandom/0.3.2/getrandom/#opt-in-backends) does not prevent wasm-bindgen from being imported when targeting wasm32-unknown-unknown for deployment on the Internet Computer (IC). Despite disabling default features and enabling the custom backend via --cfg getrandom_backend="custom", the resulting WASM file still contains __wbindgen_describe imports, causing deployment failures on IC.
Expected Behavior
According to the documentation, defining __getrandom_v03_custom and enabling the custom backend should override the default wasm_js backend, avoiding the dependency on wasm-bindgen and its associated imports (e.g., __wbindgen_describe).
Actual Behavior
Even with the custom function defined and the configuration applied, wasm-bindgen is still linked into the final WASM binary, as verified by wasm-objdump -x. This leads to deployment errors on the Internet Computer, which does not support wasm-bindgen imports.
According to my query, the dependency chain is: burn -> rand -> getrandom
You should find a crate which enables the wasm_js feature for getrandom in your dependency tree and ask its authors to not do that (or patch the dep). Unfortunately, configuration flags can not influence dependency resolution, so by enabling the wasm_js feature wasm-bindgen gets compiled as part of your project.
It does not matter. As far as I understand, you have a problematic crate in your dependency tree which enables the wasm_js feature for getrandom v0.3. We can not do anything about it on our side.
It was resolved by not enabling the wasm_js feature in the dependency, correct? We would like to check whether enabling the feature still results in the same problem (see #726), i.e. whether having wasm-bindgen/js-sys in dependency tree without calling any code from them breaks your build.
It was resolved by not enabling the wasm_js feature in the dependency, correct? We would like to check whether enabling the feature still results in the same problem (see #726), i.e. whether having wasm-bindgen/js-sys in dependency tree without calling any code from them breaks your build.
No, upon checking, I found that the other party hadn't enabled the wasm option, forcing the use of the default getrandom configuration, which caused this error. I contacted the burn framework author and had them support my use of wasm, so the issue has now been resolved.
Activity
newpavlov commentedon Mar 21, 2025
You should find a crate which enables the
wasm_jsfeature forgetrandomin your dependency tree and ask its authors to not do that (or patch the dep). Unfortunately, configuration flags can not influence dependency resolution, so by enabling thewasm_jsfeaturewasm-bindgengets compiled as part of your project.newpavlov commentedon Mar 21, 2025
We will add a stronger warning for
wasm_js(see #633). Since it's a downstream issue, we can not do much here, so I will close this issue.e274426380 commentedon Mar 24, 2025
But as far as I know, the getrandom project using version 0.2.9 works fine on Internet Computer.
And use this configuration:
features = [“custom”]https://github.com/smallstepman/ic-mnist
newpavlov commentedon Mar 24, 2025
It does not matter. As far as I understand, you have a problematic crate in your dependency tree which enables the
wasm_jsfeature forgetrandomv0.3. We can not do anything about it on our side.dhardy commentedon Sep 22, 2025
Is this issue reproducible today? The code linked above no longer exists.
e274426380 commentedon Sep 22, 2025
I'm using the burn framework. After contacting the author of burn to modify the dependencies, the issue was resolved.
newpavlov commentedon Sep 22, 2025
It was resolved by not enabling the
wasm_jsfeature in the dependency, correct? We would like to check whether enabling the feature still results in the same problem (see #726), i.e. whether havingwasm-bindgen/js-sysin dependency tree without calling any code from them breaks your build.e274426380 commentedon Sep 22, 2025
No, upon checking, I found that the other party hadn't enabled the wasm option, forcing the use of the default getrandom configuration, which caused this error. I contacted the burn framework author and had them support my use of wasm, so the issue has now been resolved.