Variables never read or used, Failed to convert at JsValue wasm bindgen
⚓ Rust 📅 2025-10-31 👤 surdeus 👁️ 11I'm working on implementing a QUIC, and WebTransport client and server in the browser. I'm simultaneously trying to compile a Node.js Addon-based respository that depends on quiche written in C++ to WASM with WASI support, and a repository that uses quinn-wasm in Rust to WASM GitHub - guest271314/quinn-wasm at direct-sockets.
A fellow developer got the QUIC code started in Rust part. I modified the original code a few minutes ago, mainly to get the Isolated Web App code to compile and run correctly in the browser. I change some Rust code to set the port to 8081 instead of 0, which UDPSocket in the browser throws for; port can't be 0.
After compiling with rustup wasm-pack build --target web --out-dir pkg I got these warnings, the compilation completed anyway
warning: fields `readable` and `writable` are never read
--> src/direct_sockets.rs:97:5
|
96 | pub struct DirectSocketUdp {
| --------------- fields in this struct
97 | readable: Mutex<Pin<Box<web_sys::ReadableStream>>>,
| ^^^^^^^^
98 | writable: Mutex<Pin<Box<web_sys::WritableStream>>>,
| ^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: method `write_to_socket` is never used
--> src/direct_sockets.rs:125:14
|
115 | impl DirectSocketUdp {
| -------------------- method in this implementation
...
125 | async fn write_to_socket(&self, message: UdpMessage) -> Result<(), ...
| ^^^^^^^^^^^^^^^
warning: `quinn-wasm` (lib) generated 2 warnings
Compiling quinn-wasm-direct-sockets v0.1.0 (/media/user/1/quinn-wasm/examples/direct-sockets-web)
Finished `release` profile [optimized + debuginfo] target(s) in 2.50s
Installing the IWA and running the code I'm getting an error in JsValue (wasm bindgen) in the browser
Error: Failed to convert to UDPSocketStreams: JsValue(Object({"localAddress":"0.0.0.0","localPort":8081,"readable":{},"writable":{}}))
I'm trying to figure out if that's the readable and writable that are never used in the Rust code; if the WHATWG ReadableStream and WritableStream are not getting converted to corresponding Rust, and compiled WASM values - and how to fix that part?
1 post - 1 participant
🏷️ Rust_feed