-
Notifications
You must be signed in to change notification settings - Fork 214
Figure out how to manage future getrandom
upgrades
#792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Why not vendor in the new getrandom impl? That would allow skipping the environment variable check? As far as I can see this crate only uses |
That looks like it could work 👍 If So, I think we just have to try something and see how it works out. |
Ok, so to sum up, the official way to do this in - js = ["dep:wasm-bindgen", "getrandom?/js"]
+ js = ["dep:wasm-bindgen", "getrandom?/wasm_js"] But then to actually use it the end user targetting [target.wasm32-unknown-unknown]
rustflags = ['--cfg', 'getrandom_backend="wasm_js"'] Otherwise no
So one option would be for The other option would of course be to not do anything special because people will probably need to add the |
I think it was a bit of a lazy mistake on my part for us to rely so directly on
This sounds like it should work 👍 We can then also call out in our docs that |
One other issue I just noticed is that the |
On WASM I think we can make that feature a no-op and continue to use our vendored code instead. It's mostly useful on Windows where the system crypto APIs are surprisingly slow |
That seems logical... I ended up accidentally stumbling on this after going down a bit of a rabbit hole to upgrade some dependencies today 😅 (Unfortunately, I do currently have to maintain a direct dependency on |
I'm working through this now 👍 I think the scenarios we're still likely to break are those using |
Won't this still break it for no-std that isn't wasm? E.g microcontrollers. We sometimes have to deal with UUIDs in network protocols still. I don't personally need the rng, but I see no reason you couldn't hook it up to a simple shift register or a true hardware rng on a microcontroller if your project needs that. Perhaps you should simply consider bumping your own major version instead? That seems like the only right way to do this. |
Users in other no-std environments can still upgrade |
So I ran into the same problem outside of |
@mitsuhiko The piece that’s missing here is a stable interface to configure randomness on platforms that don’t have an obvious source. That seems like something we could all solve in a way that’s independent of Yeh it would be a terrible midpoint for everyone to go and define their own interface. It would make trying to configure a project of any meaningful size on a non-standard platform a total pain. |
For this release and If you're specifically in |
getrandom
to 0.3
getrandom
upgrades
Perhaps it would be useful to have |
@ChrisDenton, this actually is supported via a type called |
Just food for though. IMHO it seems that the root of the issue is that generating the Uuid and it's representation reside in the same crate. Representing In fact, if I recall correctly, v7 generator has to rely on thread local (or global) state. That seems too much for a crate that is so basic (as in, being tue base for a lot of other things). |
@Andrepuel This is basically the problem, specifically that all this functionality lives on the At this stage though the ship has sailed on those kinds of changes. I'm not planning any major version of |
We hit this problem and the changes to depend instead on the [target.wasm32-unknown-unknown]
rustflags = ['--cfg', 'getrandom_backend="wasm_js"'] Yields,
There are a few crates with Found some discussion |
@heaths Ah, on You should be able to fix the
|
Thanks. That gives me some options to try. I did add multiple versions similar to what you have above, but the Fortunately, I was able to roll back the updates to |
When I tested a wasm build using both |
Yeah, but we also have a ton of dependencies in a monorepo/workspace that may factor in somehow. I can create a simple little scratch workspace and try it when I catch up to the can I kicked down the road. |
Hi! I'm encountering an issue when building my Rust project for wasm32-unknown-unknown. My project does not directly depend on getrandom, uuid, or rand, but it does use surrealdb and many popular crates, which depends on them internally. I get the same error, during compilation:
I have already attempted the fixes you suggest, but none resolved the issue in my case. What would be the best way to resolve this problem? |
I have a running leptos 0.7.7 surrealdb 2.2.0 application. Try this both things as described before: In your global .cargo add a config.toml (if not already present) with the following content. Maybe it also could be placed locally in your application.
Then update your local Cargo.toml with this dependencies:
|
Per Rust docs: just create a = clean (per project/app) workaround for the issues affecting (for now) contexts like Leptos, Dioxus, ... (and also quite useful for a few other crates faking data). |
I've just created new leptos project and added to dependencies only
Did you have the same? |
Okey, I figured out that it should be |
Executing 'cargo update' will fetch new versions of uuid and getrandom which will cause artifex-batch to fail to build for the target wasm32-unknown-unknown: ```sh cargo build -p artifex-batch --target wasm32-unknown-unknown ``` So update the crates and the build options. See [1], [2]. [1] uuid-rs/uuid#792 [2] https://docs.rs/getrandom/latest/getrandom/#webassembly-support
It looks like
getrandom
's0.3.x
release treats wasm targets a bit differently than0.2.x
. Inuuid
, we just require ajs
feature to support RNG inwasm32-unknown-unknown
viagetrandom
, which sniffs out web crypto APIs. In0.3.x
, it looks like you need to setRUSTFLAGS
to make this work. If we upgrade our version ofgetrandom
, we'll break existing users of it via thejs
feature.We may just need to vendor in the old
getrandom
impl, so long as we can still compilegetrandom
0.3.x
onwasm32-unknown-unknown
without settingRUSTFLAGS
.The text was updated successfully, but these errors were encountered: