Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

youknowone
Copy link
Member

@youknowone youknowone commented Aug 31, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability of WebAssembly builds by ensuring correct random number generation in browsers (wasm_js backend), reducing initialization errors in non-WASI WASM environments.
  • Chores

    • Consolidated WASM build configuration at the workspace level for consistent behavior across platforms.
    • Added target-specific dependency for wasm32 (non-WASI) to streamline builds.
    • Removed redundant per-package WASM config to reduce duplication and maintenance overhead.

Copy link
Contributor

coderabbitai bot commented Aug 31, 2025

Walkthrough

Adds wasm32-unknown-unknown rustflags in top-level Cargo config, introduces a wasm32 (non-WASI) target-specific dependency on getrandom with the wasm_js feature in common/Cargo.toml, and removes the redundant wasm32 rustflags from wasm/lib’s local Cargo config. Build target for wasm/lib remains wasm32-unknown-unknown.

Changes

Cohort / File(s) Change summary
Top-level Cargo target config
/.cargo/config.toml
Adds [target.wasm32-unknown-unknown] with rustflags = ["--cfg=getrandom_backend=\"wasm_js\""]. Other targets unchanged.
WASM library local config cleanup
/wasm/lib/.cargo/config.toml
Removes local [target.wasm32-unknown-unknown] rustflags; retains [build] target = "wasm32-unknown-unknown".
Target-specific dependency (wasm32, non-WASI)
/common/Cargo.toml
Adds target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies with getrandom = { workspace = true, features = ["wasm_js"] }.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump the ground—compile-time cheer,
For wasm winds are crystal clear.
A dash of flags, a feature’s glow,
getrandom hops where bytes must flow.
From burrow builds to browser sky,
My whiskers twitch—ship it, aye! 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
.cargo/config.toml (1)

7-8: Workspace-level wasm_js cfg looks good; minor quoting/style nit and scope check

Moving the cfg to the top-level target is the right direction. Two nits:

  • Use single-quoted TOML to avoid inner escapes.
  • Confirm this broad workspace-level cfg is intended for all crates when building for wasm32-unknown-unknown (it will apply to all members and their deps for that target).

Apply within this hunk:

-[target.wasm32-unknown-unknown]
-rustflags = ["--cfg=getrandom_backend=\"wasm_js\""]
+[target.wasm32-unknown-unknown]
+rustflags = ['--cfg=getrandom_backend="wasm_js"']
common/Cargo.toml (1)

39-41: Double-check getrandom feature name; likely unnecessary/incorrect here

Please verify that getrandom provides a feature literally named "wasm_js". If not, this will fail or be a no-op; the backend selection is already driven by the cfg you added via rustflags. If the cfg is sufficient (it usually is), drop the feature and possibly the whole target-specific dep block to avoid confusion/duplication with the global getrandom dep on Line 22.

Option A — keep the block but remove the feature:

 [target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies]
-getrandom = { workspace = true, features = ["wasm_js"] }
+getrandom = { workspace = true }

Option B — remove the redundant block entirely (global dep already exists):

-[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies]
-getrandom = { workspace = true, features = ["wasm_js"] }

Also, if the workspace isn’t on Cargo feature resolver = "2", consider enabling it at the workspace root to prevent unintended feature unification across targets.

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7509387 and fdf5f3e.

📒 Files selected for processing (3)
  • .cargo/config.toml (1 hunks)
  • common/Cargo.toml (1 hunks)
  • wasm/lib/.cargo/config.toml (0 hunks)
💤 Files with no reviewable changes (1)
  • wasm/lib/.cargo/config.toml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Run tests under miri
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Check Rust code with rustfmt and clippy
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Ensure compilation on various targets
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)

@coolreader18
Copy link
Member

Ah, actually - that test failure is why the config is the way it is. Putting it in the top level means js gets selected even when we're not compiling wasm for browser.

Comment on lines +39 to +41
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies]
getrandom = { workspace = true, features = ["wasm_js"] }

Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies]
getrandom = { workspace = true, features = ["wasm_js"] }

This is wrong.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, true. I guess that should be enabled by a js feature flag that common exposes.

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.

2 participants