wrap-cli
wrap-cli copied to clipboard
Wasm memory errors in uniswap v3 front end
Describe the bug I've been getting memory-related WebAssembly errors in the uniswap v3 front end. It leads to the browser tab freezing and I need to force quit my browser.
Some notable points:
- the issue usually only happens when I'm trying to use the app on Polygon
- the browser memory profile says there is no issue with the JS heap growing large
- I am not using any recursion
index.js:1 Error: Unable to find Wasm memory import section. Modules must import memory from the "env" module's "memory" field like so:
(import "env" "memory" (memory (;0;) #))
at AsyncWasmInstance.createMemory (AsyncWasmInstance.ts:77:1)
at WasmWrapper.<anonymous> (WasmWrapper.ts:182:1)
at step (index.ts:27:1)
at Object.next (index.ts:27:1)
at fulfilled (index.ts:27:1)
There is also a "could not compile" error sometimes but it's more rare. I'll add a screenshot when I am able to recreate it.
Please provide the steps to reproduce and if possible a minimal demo of the problem.
I'm not sure how to reproduce the bug in a new app. I have only ever seen this bug in the uniswap v3 front end. There are two ways to reproduce the errors in the uniswap v3 front end:
Method 1: Go to https://polywrap-uniswapv3.on.fleek.co/#/swap and open the browser console. Connect your metamask wallet, select tokens for a trade, input numbers, and watch the console.
Method 2: clone this repo https://github.com/polywrap/uniswap-interface and checkout the polywrap-v3
branch. Then run nvm use && yarn && yarn start
and open the browser console. Connect your metamask wallet, select tokens for a trade, input numbers, and watch the console.
Screenshots / logs
Relevant environment details:
- Brave browser
Related: check what happens if we allocate large amount of memory in Wasm
TODO: try reproducing this with the 0.9.5
client, to see if there are more error details available since debug information has been improved.
Update: Kris has updated the demo app, and found less errors. We also suspect that after this fix is released, we'll see less memory related errors as well: https://github.com/polywrap/toolchain/pull/1528
NOTE: we've discussed this in detail, and done lots of testing. We plan on implementing a configurable "limits" section within the client, to allow developers to limit the number of asynchronous invocations going through the client. This will help with limiting the growth of memory inside applications.
Moving this out of origin-qa, since we aren't using the uniswap-interface fork for demoing the wrapper anymore.