rustrust-tonicleptos

Using Tonic (gRPC) & Leptos (WASM)


I am trying to use both Tonic (gRPC) & Leptos (WASM) together. I've tried with other WASM frameworks (Yew & Dioxus) which works well, but Leptos returns the following 2000+ line long error.

...

"/Users/vb/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/librustc_std_workspace_alloc-c38a59bfc0e9dbea.rlib"
 "/Users/vb/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libminiz_oxide-64c97e1f297aaa2a.rlib" "/Users/vb/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libadler-41daeb18b4cf5212.rlib" 
"/Users/vb/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libunwind-2e14c4e869ef0095.rlib" "/Users/vb/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libcfg_if-6ab2d55e0fc6736f.rlib" 
"/Users/vb/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/liblibc-b63bc9b0d1ee276a.rlib" "/Users/vb/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/liballoc-7a6735befdece646.rlib" 
"/Users/vb/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/librustc_std_workspace_core-907cd1f856ca6753.rlib" "/Users/vb/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libcore-808c25238bc298db.rlib" 
"/Users/vb/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-6e2299aadeb4eab9.rlib" "-L" 
"/Users/vb/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib" "-L" "/Users/vb/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/self-contained" "-o" "/Users/vb/Documents/Github/tonic-web-leptos-minimal/client/target/wasm32-unknown-unknown/debug/deps/client-b6b34c1043101ef6.wasm" "--gc-sections" "-O0"

...

          rust-lld: error: duplicate symbol: intounderlyingsource_pull
          >>> defined in /Users/vb/Documents/Github/tonic-web-leptos-minimal/client/target/wasm32-unknown-unknown/debug/deps/libwasm_streams-c0e6bacf3ec8ab2b.rlib(wasm_streams-c0e6bacf3ec8ab2b.wasm_streams.e355e7508143bf01-cgu.7.rcgu.o)
          >>> defined in /Users/vb/Documents/Github/tonic-web-leptos-minimal/client/target/wasm32-unknown-unknown/debug/deps/libwasm_streams-21e4560d2007218a.rlib(wasm_streams-21e4560d2007218a.wasm_streams.fe87211425a80c26-cgu.8.rcgu.o)

          rust-lld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)


warning: `client` (bin "client") generated 1 warning
error: could not compile `client` (bin "client") due to 1 previous error; 1 warning emitted
2024-02-06T22:49:26.254651Z ERROR ❌ error
error from build pipeline

Caused by:
    0: HTML build pipeline failed (1 errors), showing first
    1: error from asset pipeline
    2: error during cargo build execution
    3: cargo call to executable 'cargo' with args: '["build", "--target=wasm32-unknown-unknown", "--manifest-path", "/Users/vb/Documents/Github/tonic-web-leptos-minimal/client/Cargo.toml"]' returned a bad status: exit status: 101

Has anyone who encountered this error before suggest a potential solution?

I have checked this, this and this out, to no avail. It seems to be a problem that mostly embedded Rust people encounter.


Solution

  • I just came across this issue, it means you have two different versions of wasm-streams being required. Check your Cargo.toml for the conflicting versions and see if you can trace back to where the discrepancy is.

    You'll see something like this

    "wasm-streams vX.X.X"

    and somewhere else

    "wasm-streams vY.Y.Y"

    It can be a bit tricky to track down but cargo tree can help.