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.
Verification
- Increasing the WASM stack using (
.cargo/config.toml)increased the number of events until the error occurred.rustflags = ["-C", "link-args=-z stack-size=150000000"] - Modifying
tauri-sys::event::listento first serialise theJsValue(usingjs-sys::JSON::stringify), then deserialize it withserde_json::from_strcompletely resolved the issue. (AI explanation) This works becauseserde-wasm-bindgen::from_valuecreates a new WASM function for every field in the struct as it's deserialised, whileserde_jsondoes not.
Source: wasm-bindgen/wasm-bindgen