Skip to content

Remove all uses of getrandom_backend = "wasm_js"#771

Merged
newpavlov merged 11 commits into
masterfrom
rm_wasm_js_cfg
Jan 7, 2026
Merged

Remove all uses of getrandom_backend = "wasm_js"#771
newpavlov merged 11 commits into
masterfrom
rm_wasm_js_cfg

Conversation

@newpavlov
Copy link
Copy Markdown
Member

Enabling the wasm_js crate feature is sufficient.

@newpavlov newpavlov requested a review from dhardy December 27, 2025 17:55
Copy link
Copy Markdown
Member

@dhardy dhardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removal of getrandom_backend="wasm_js" is a breaking change; it makes sense to merge this before 0.4 (I assume this is your intention).

Comment thread .github/workflows/tests.yml
Comment thread Cargo.toml Outdated
# i.e. avoid unconditionally enabling it in library crates.
#
# WARNING: This feature SHOULD be enabled ONLY for binary crates and tests. In other words,
# avoid enabling it in library crates whether unconditionally or gated on a crate feature.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or gated on a crate feature

I see no hard reason not to have a "forwarding" feature flag (e.g. wasm_js = ["getrandom/wasm_js"]).

I know you don't like this pattern, but I don't think directing users like this will work particularly well.

I suggest we keep our advice direct and minimally opinionated:

We recommend against enabling this feature in libraries (except for tests) since it is known to break some non-Web WASM builds and further since the usage of wasm-bindgen causes significant bloat to Cargo.lock (on all targets).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having a default guidance against forwarding crate features is a reasonable. It's mostly that you run into semver and stability issues when trying to forward the features of other crates. It's possible to do, but really only works if:

  • you pay extra close attention to the issues
  • you work closely between the forwarding crate and getrandom (like rand does).

@newpavlov newpavlov requested a review from dhardy December 31, 2025 07:44
Copy link
Copy Markdown
Member

@josephlr josephlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this seems reasonable if it's part of a breaking change for 0.4 (and the changes to tests/documentation might be good to also have in 0.3).

It might be worth mentioning (somewhere) that we used to allow --cfg getrandom_backend="wasm_js" (but don't anymore for 0.4)

@josephlr josephlr mentioned this pull request Dec 31, 2025
3 tasks
Copy link
Copy Markdown
Member

@dhardy dhardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I approve.

Comment thread Cargo.toml Outdated
@newpavlov
Copy link
Copy Markdown
Member Author

newpavlov commented Jan 7, 2026

It might be worth mentioning (somewhere) that we used to allow --cfg getrandom_backend="wasm_js"

This change does not "forbid" --cfg getrandom_backend="wasm_js" in any way. It's simply gets ignored and the only visible consequence is lack of the compilation error which warns users to enable the wasm_js feature (instead users will get a different compilation error).

So, arguably, this change is not a breaking one and arguably we should've done it as part of the v0.3.4 release.

@newpavlov newpavlov merged commit e49dacc into master Jan 7, 2026
75 checks passed
@newpavlov newpavlov deleted the rm_wasm_js_cfg branch January 7, 2026 23:09
takumi-earth pushed a commit to earthlings-dev/getrandom that referenced this pull request Jan 27, 2026
Enabling the `wasm_js` crate feature is sufficient.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants