question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WalletConnect v2 subscriptions storage issue leading to freeze/crash

See original GitHub issue

Hey,

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:

  1. Go to https://use-contractkit-c-labs.vercel.app/
  2. Tap Connect
  3. Scan the QR code with Valora (note that we’ve remotely disabled WC v2 in the production versions of Valora because of this issue)
  4. Sign some things (not sure it’s needed though)
  5. Let the tab open for a while
  6. 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: Screenshot 2021-10-19 at 09 38 57

And here are the other parts of the stored state that may be of interest. Screenshot 2021-10-19 at 09 39 11 Screenshot 2021-10-19 at 09 39 16 Screenshot 2021-10-19 at 09 39 19 Screenshot 2021-10-19 at 09 39 22 Screenshot 2021-10-19 at 09 39 31

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:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
pedrouidcommented, Mar 29, 2022

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

3reactions
jeanregissercommented, Oct 19, 2021

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 to 2.0.0-beta.19.

Screenshot 2021-10-19 at 14 01 49 Screenshot 2021-10-19 at 14 06 58

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Websocket connection failed · Issue #548 - GitHub
It is caused by the overload bridge server, the new version will select a server randomly. My env: web3modal + walletconnect provider 1.5.1....
Read more >
Wallet Usage - WalletConnect Docs
When your Sign instance receives requests from a peer it will publish a related event. Set a subscription to handle them. To track...
Read more >
WalletConnect
WalletConnect is an open source protocol for connecting decentralised applications to mobile wallets with QR code scanning or deep linking.
Read more >
WalletConnect Docs: About
WalletConnect is the decentralized Web3 messaging layer and a standard to connect blockchain wallets to dapps. Our mission continues to expand ...
Read more >
Migrating from v1.x - WalletConnect Docs
Migration schedule​. WalletConnect v2.0 is NOT backwards-compatible with v1.0. Therefore we must coordinate a migration schedule to ensure end- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found