WalletConnect v2 subscriptions storage issue leading to freeze/crash
See original GitHub issueHey,
We discovered a problem with WalletConnect v2 stored subscriptions leading to a freeze/crash. Unfortunately we haven’t yet pinpointed the exact steps to reproduce this, however we’ve gathered some data about what’s happening.
Problem
We initially spotted the issue in our Valora wallet. See https://github.com/valora-inc/wallet/issues/1215. But then noticed it’s happening on the test web app we use too: https://use-contractkit-c-labs.vercel.app/
Approximate repro steps on the web app:
- Go to https://use-contractkit-c-labs.vercel.app/
- Tap Connect
- Scan the QR code with Valora (note that we’ve remotely disabled WC v2 in the production versions of Valora because of this issue)
- Sign some things (not sure it’s needed though)
- Let the tab open for a while
- Refresh it, it will eventually crash
This is happening with @walletconnect/client
2.0.0-beta.18
.
The main problem is a huge number of subscriptions end up being stored in local storage (8000+).
Once the client tries to restore them in a Promise.all
call when initializing, it blows up (Chrome page errors, mobile app crashes, running out of memory). https://github.com/WalletConnect/walletconnect-monorepo/blob/56db6e088d55146249788b8a27dfb9609f5f297b/packages/client/src/controllers/relayer.ts#L291-L300
Data
Here’s the data causing this (took some screenshots, but I can provide the raw data too).
You can see it’s storing 8000+ subscriptions for basically 2 different topics:
And here are the other parts of the stored state that may be of interest.
I’ve also been able to capture the logs of Valora with WalletConnect logger in trace
mode.
Note that there’s a misleading log statement:
[Fri Oct 15 2021 15:47:18.275] DEBUG {"context": "client"} [{"context": "client/relayer"}, {"context": "client/relayer/subscription"}, "Successfully Restored subscriptions for relayer subscription"]
[Fri Oct 15 2021 15:47:18.281] TRACE {"context": "client"} {"context": "client/relayer"} {"context": "client/relayer/subscription"} {"method": "restore", "subscriptions": [], "type": "method"}
It says the subscriptions are empty when it was actually 8000+ items. Not sure why it doesn’t display them.
Let me know if you need any other info.
Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:20 (7 by maintainers)
Top GitHub Comments
We had to push some fixes on top of the last release
Please use beta.26 instead
https://github.com/WalletConnect/walletconnect-monorepo/releases/tag/2.0.0-beta.26
The problem can be reproduced with
2.0.0-beta.19
😢Using https://react-app.walletconnect.org/ (it’s using
2.0.0-beta.19
, right?) and a local build of Valora where I updated to2.0.0-beta.19
.Still a bit unsure of the exact steps, what I describe above still applies, but I also let the computer sleep and after I came back I directly saw the issue. This seems to indicate the WalletConnect client reconnection logic may lead to this issue.