-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
memory access out of bounds #3153
Comments
It seems like the wasm module is getting re-initialized after a closure is created, resetting the Rust code's memory and causing an out-of-bounds error because the memory referenced by the closure no longer exists. The wasm module gets initialized here: That runs after every render (according to a quick skim of React's docs, anyway), and resets the wasm module every time. You need to add some kind of guard to only initialize the wasm module if it's not already initialized ( |
@Liamolucko thanks, that's it! The effect is running twice because of React's strict mode. With ( |
See rustwasm/wasm-bindgen#3153 for context
* Fix "memory access out of bounds" error See rustwasm/wasm-bindgen#3153 for context * Use useEffect
* Fix "memory access out of bounds" error (#77) * Fix "memory access out of bounds" error See rustwasm/wasm-bindgen#3153 for context * Use useEffect * hook: `useMountEffectOnce` * version: 1.3.8 Co-authored-by: ivanschuetz <ivanschuetz@gmail.com>
Describe the Bug
When calling an async function that makes a reqwest call, there's a "memory access out of bounds" error. This seems to be specific to
web
target / next.js configuration.Steps to Reproduce
Expected Behavior
The page shows "Computed from WASM: 4+3=7" text and there are no errors on the console.
Actual Behavior
The page shows "Computed from WASM: 4+3=undefined" text and there's a "memory access out of bounds" on the console.
Additional Context
The error project is based on a working template (https://github.com/satelllte/nextjs-wasm). The changes in the error project are making the WASM function async and using reqwest.
Error:
The text was updated successfully, but these errors were encountered: