WASM function table exhaustion with repeated `serde_wasm_bindgen::from_value()` in closures

Author: bicarlsenCreated Sep 6, 2026Updated Sep 7, 2026

Context

A tauri + leptos app that uses tauri-sys to listen to tauri events from leptos. tauri-sys::event::listen calls serde-wasm-bindgen::from_value to deserialize events.

On macOS 12.7.6.

Issue

After deserializing several events using serde-wasm-bindgen::from_value a RuntimeError: Out of bounds table access occurs. This appears to be caused by a memory leak.

stacktrace.log

Verification

  1. Increasing the WASM stack using (.cargo/config.toml)
    toml
    rustflags = ["-C", "link-args=-z stack-size=150000000"]
    increased the number of events until the error occurred.
  2. Modifying tauri-sys::event::listen to first serialise the JsValue (using js-sys::JSON::stringify), then deserialize it with serde_json::from_str completely resolved the issue. (AI explanation) This works because serde-wasm-bindgen::from_value creates a new WASM function for every field in the struct as it's deserialised, while serde_json does not.

Source: wasm-bindgen/wasm-bindgen